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 }

Leave a comment