How to change the BackColor of a ComboBox when DropdownStyle is DropDownList? How to change the BackColor of a ComboBox when DropdownStyle is DropDownList? windows windows

How to change the BackColor of a ComboBox when DropdownStyle is DropDownList?


You can set FlatStyle property to Popup. This way the back color will use in both DropDown and DropDownList mode.

If you don't like flat style or you need more customization on rendering of ComboBox, you can use an owner-drawn ComboBox. For example you can set DrawMode property to OwnerDrawFixed and handle DrawItem event and draw the combo box based on your logic.


I have been using stack overflow for a couple of years without subscribing or contributing. It's my first choice whe looking for a solution because it generally supplies a solution and I can read it without having to zoom. At 81 years of age, I am fossilized, but "It’s kind of fun to be extinct."Thanks, Ogden Nash.

When background shading is applied to text, the reduced contrast makes it difficult for my old eyes to read it. I Googled the problem, and the offered solutions scared me off.I even considered cobbling up the functionality using graphics, but I needed several instances. Gotta be a way.

Cover the text part of the combobox with a textbox, and change the textbox to multiline to make its height match the combobox. Add a couple of event handlers and Bob's your uncle.

Private Sub cmbPoints_SelectedIndexChanged(sender As Object, e As EventArgs                                     )HandlescmbPoints.SelectedIndexChanged  ' Make the selection visible in the textbox  txtPoints.Text = cmbPoints.TextEnd SubPrivate Sub txtPoints_GotFocus(sender As Object, e As EventArgs                              ) Handles txtPoints.GotFocus  ' Prevent the user changing the text.  cmbPoints.Focus()End Sub


Just like mentioned above; You can set FlatStyle property to Popup/Flat. This way the back color will use in both DropDown and DropDownList mode.

But then you wont have the look you expected.There's a trick i do where i create a panel and change its border property to FixedSingle. Change the color of the panel to as desired and then change its size property to match the size of your ComboBox. Eg to 80, 22.On the position where you had your ComboBox, place your panel. Place your combobox on the Panel. If you can fine tune its position, When you debug, you will find that your ComboBox looks like it has a border.