Question ComboBox Selection Color

SQLServant

New member
Joined
Jan 23, 2012
Messages
2
Programming Experience
10+
I have a Win Forms app written in vb.net. In it, I have a combo box with a Owner Draw Item routine. Using this routine, I am able to implement an application-wide default value for a selection color like shown below:

ComboImage1.png
This works great except for one tidbit: Once an item is selected, the combo box reverts to showing the system selection color again :(
ComboImage2.png

How can I also use my own selection color in the textbox portion of the combo box, after the user makes a selection?
 

Tom Giles

New member
Joined
Jan 27, 2012
Messages
2
Location
Ottawa, Ontario, Canada
Programming Experience
3-5
Hi all, first post! Great forum.

I have a very similar issue with the color parameter [system.windows.forms.combobox].ForeColor

When I set forecolor, the color is never applied to the selected value, only the values in the list. Same goes for backcolor, so it's interesting to read your post.

I'm using a dropdownlist type for the list - my Forecolor setting works when I use a DropDown style.

Anyone have a fix to setting the DropDownList-type combobox selected-item text color? (phew... what a mouthful)

Cheers
Tom
 

SQLServant

New member
Joined
Jan 23, 2012
Messages
2
Programming Experience
10+
Adding the following line fixed my issue:
Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList

I thought this line was unnecessary (a default value)... I was wrong.
 

Tom Giles

New member
Joined
Jan 27, 2012
Messages
2
Location
Ottawa, Ontario, Canada
Programming Experience
3-5
Thanks for the reply sqlservent. Interesting line, I will have to try it out.

I fixed my color issue with setting the FlatStyle=Flat. This changed the nice visual appearance to a more win xp style but it worked.

Cheers
Tom
 
Top Bottom