1

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 something along these lines:

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

Thanks.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
Jim Fell
  • 13,750
  • 36
  • 127
  • 202

1 Answers1

5

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

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501