Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combobox DropDownList Style with white background

Tags:

c#

combobox

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.

DropDownList: DropDownList

DropDown: DropDown

like image 450
user3424480 Avatar asked Jul 30 '16 22:07

user3424480


1 Answers

To make a ComboBox DropDownList look like a ComboBox DropDown:

  1. Add a ComboBox to the WinForm. Go to Properties Explorer. Select DropDownStyle > DropDownList. Then select FlatStyle > Flat.
  2. Add a Panel to the WinForm. Go to Properties Explorer. Select BorderStyle > FixedSingle.
  3. Drag ComboBox onto Panel. With ComboBox active, go to Properties Explorer > Dock > Fill.
  4. With ComboBox active, hold the ‘Shift’ key, select the Panel to make it active as well (order of selection is important).
  5. Go to the Layout Toolbar (View > ToolBars > Layout) and select ‘Make Same Size’.
  6. When you run your program, the DropDownList ComboBox should look like a DropDown ComboBox
like image 148
Cruzer Avatar answered Nov 16 '22 02:11

Cruzer