mpdalton
asked on
Resize Combobox
i want to resize my comboboxes to match the size of the textboxes.
i've seen that i can use:
cbo.DrawMode = DrawMode.OwnerDrawFixed
cbo.ItemHeight =15
to specify a custom height.
the problem is that once i do that i can't see any items in the comboxbox dropdown. The dropdown is the correct height for the number of items, and if i click inside the dropdown it selects the text thats there, just i can't see the text.
i'm thinking i need to capture some event and maybe call the base class, just not sure which one or if i'm on the right track.
When you set the drawMode property of the comboBox to DrawMode.OwnerDrawFixed, you have to draw you items by code, you are indicating that you want to paint your control as you want, thats the reason because you see nothing.
ASKER
any code snippets that might show me how to do that ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry I wrote Brushes.Blue
it will show the Items in Blue color make it Brushes.Black
it will show the Items in Blue color make it Brushes.Black
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My apologies, 3 minutes slow ;), arif_eqbal has the same code.
ASKER
thanks for your replies.
the comboboxes i'm using are bound to a datatable to when the e.graphics.drawstring method is called it generates an error:
"Cast from type 'DataRowView' to type 'String' is not valid."
is it possible to use this method with a bound combobox ?
the comboboxes i'm using are bound to a datatable to when the e.graphics.drawstring method is called it generates an error:
"Cast from type 'DataRowView' to type 'String' is not valid."
is it possible to use this method with a bound combobox ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Keep in mind that example is in C#, but you can see how it applies to VB.NET, however if you need a hand converting just ask.
James
James
ASKER
Brilliant, thanks everyone it's working perfectly now ... finally all my controls are the same height.
i'm a happy man :-)
i'm a happy man :-)