小编Isa*_*ron的帖子

获取资源文件夹路径c#

我在项目中的一些资源很好,使用字符串路径工作正常但如果我将项目移动到另一个目录或另一台计算机,它将停止工作.

我需要在字符串变量中获取项目的resources文件夹的路径,

像这样的东西

C:\Users\User1\Documents\<projects folder>\<project name>\Resources\
Run Code Online (Sandbox Code Playgroud)

提前致谢.

c# path

6
推荐指数
2
解决办法
3万
查看次数

组合框项目太长

我的组合框中的某些项目长度超过 20 个字符,我编写了此代码以使它们变小并添加“...”,但它\xc2\xb4s 不起作用。\n通过示例而不是“comboboxitemnumberthird”,它看起来像this:"comboboxitemnu..." 以适应组合框的大小

\n\n
i=0;\ndo\n{\n    var item = comboBox1.Items[i].ToString();\n    if (item.Length >= 17) // not sure about this part\n    {\n        item = item.Substring(0, item.Length - 6) + "...";\n    }\n    i++;\n} while (i < comboBox1.Items.Count); //finishes when theres not any other item left on the combobox\n
Run Code Online (Sandbox Code Playgroud)\n\n

请让我知道出了什么问题。提前致谢。

\n

c# combobox winforms

0
推荐指数
1
解决办法
2159
查看次数

标签 统计

c# ×2

combobox ×1

path ×1

winforms ×1