I want to have an uneditable ComboBox but still show a white background colour, so it is effectively styled like the default ComboBox style (DropDown). The ComboBoxStyle.DropDownList only provides the standard "disabled" looking grey back colour. Simply setting BackColor = Color.White has no effect.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
To make a ComboBox DropDownList look like a ComboBox DropDown:
Having struggled trying to get the control looking identical to the DropDown ComboBox style I had to settle with overriding the OnKeyPress event so that it restricted the user from been able to edit the control. As a side note I would also recommend overriding the appropriate event to prevent users pasting values into the ComboBox (how to disable copy, Paste and delete features on a textbox using C#).
You will have to create your own ComboBox with custom drawing or use a third-party control such as Infragistics UltraCombo
I played around with this for a while and didn't want to do anything too involved. Those ideas above probably work but all I did was change the flatStyle property from "standard" to "flat".
Although not perfect, it at least changes the background that grey/disabled look to white.
You can see the comparison here:
Heating Source #1 > DropdownList > flat (the final decision since dropdown was allowing users to enter bad data)
Heater Source #2 > Dropdown > Standard (the default which looks nice)
Housing Type > Dropdown > Flat
Heating Source #1 Vendor > DropdownList > Standard (the default which looks disabled grey)