I'm trying to change the dispaly color of a ComboBox when the DropdownStyle property is DropdownList. When the property is changed to Dropdown from DropdownList the color changes.
How can I control the view color of the dropdown boxes ?
Thanks
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.
You may also be interested in the following posts to customize ComboBox:
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.Text
End Sub
Private Sub txtPoints_GotFocus(sender As Object, e As EventArgs
) Handles txtPoints.GotFocus
' Prevent the user changing the text.
cmbPoints.Focus()
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With