【发布时间】:2014-11-15 20:10:21
【问题描述】:
我的组合框中的某些项目超过 20 个字符,我编写了这段代码以使它们更小并添加“...”,但它不起作用。 例如,而不是“comboboxitemnumberthree”,它看起来像这样:“comboboxitemnu ...”以适应组合框的大小
i=0;
do
{
var item = comboBox1.Items[i].ToString();
if (item.Length >= 17) // not sure about this part
{
item = item.Substring(0, item.Length - 6) + "...";
}
i++;
} while (i < comboBox1.Items.Count); //finishes when theres not any other item left on the combobox
请让我知道出了什么问题。提前致谢。
【问题讨论】: