开发者

Calculating ComboBox DropDownWidth in C#

In my application a ComboBox gets resized, so that it is smaller. How do I re-calculate the DropDownWidth property? I know how to set it, but I'd prefer to calculate the proper width because its contents changes. Preferabley, I was thinking of somethin开发者_StackOverflow中文版g along these lines:

int iMaxLen = 0;
foreach item in comboBoxList
{
   iMaxLen = (item.Length > iMaxLen) ? item.Length : iMaxLen;
}
comboBoxList.DropDownWidth = iMaxLen;

Thanks.


Adjust combo box drop down list width to longest string width http://www.codeproject.com/KB/combobox/ComboBoxAutoWidth.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜