The example is in C#, but it is pretty straightforward and should be easy to convert to VB.
I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
Sorry, I was pressed for time yesterday. Here's the whole thing in VB:
Dim g As System.Drawing.Graphics = ComboBox1.CreateGraphics
Dim maxWidth As Double = 0.0F
For Each o As Object In ComboBox1.Items
Dim w As Double = g.MeasureString(o.ToString(), ComboBox1.Font).Width
If (w > maxWidth) Then
maxWidth = w
End If
Next
Note the portion in red. As the code was written (using .Width instead of .DropDownWidth), it would increase the size of the combobox control. This change only affects the width of the dropdown box.
I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.