Link to home
Start Free TrialLog in
Avatar of mpdalton
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.
Avatar of eozz_2000
eozz_2000

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.
Avatar of mpdalton

ASKER

any code snippets that might show me how to do that ?
SOLUTION
Avatar of arif_eqbal
arif_eqbal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry I wrote Brushes.Blue
it will show the Items in Blue color make it Brushes.Black
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
My apologies, 3 minutes slow ;), arif_eqbal has the same code.
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 ?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Brilliant, thanks everyone it's working perfectly now ... finally all my controls are the same height.

i'm a happy man :-)