On Aug 5, 10:52*pm, Ethan Strauss
<EthanStra...@discussions.microsoft.comwrote:
Hi,
* In a C#.Net2.0 Winforms application I have some combo boxes. I ind these
boxes to enum values and then call
ComboBox.Size = ComboBox.PreferredSize:
But, the combo box is never wide enough to display long items! Isn't that
what PreferredSize is uspposed to give?
It is not. Control.PreferredSize is about sizing of controls when they
are layed out automatically (using TableLayoutPanel/FlowLayoutPanel).
Am I missing something or is there another way to make sure that my comboboxes are wide enough to display all
the text in them?
You can use ComboBox.DropDownWidth to make the width of the dropdown
list larger to accomodate long strings; but there is no way that I
know of to make it auto-sizing. If you really need it, you can use
TextRenderer.MeasureText to measure width of all items, and update
DropDownWidth according to the measurements.
Thanks!
Ethan