DataGridViewComboBoxColumn Drop Down Menu Appears All Black

This annoying bug was haunting me for quite a while. Luckily Nick Olsen figured it out

http://nickstips.wordpress.com/2010/12/20/c-datagridviewcomboboxcolumn-drop-down-menu-appears-all-black/

Code to fix

01 private void dataGridViewGLEntries_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
02 {
03     ComboBox cmbBx = e.Control as ComboBox;
04
05     if (cmbBx != null)
06     {
07         cmbBx.SelectedIndexChanged -= ComboBoxCell_SelectedIndexChanged;
08         cmbBx.SelectedIndexChanged += ComboBoxCell_SelectedIndexChanged;
09
10         // Fix the black background on the drop down menu
11         e.CellStyle.BackColor = this.dataGridViewGLEntries.DefaultCellStyle.BackColor;
12     }
13 }
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s