I ran into an issue today using the DataGridView where one of the columns defined as a DataGridViewComboBoxColumn appeared with the drop down menu completely black as shown below.
After some research I found out that there is a documented bug in the DataGridViewComboBoxColumn where this sometimes occurs if you are handling the EditingControlShowing event of the DataGridView. I am handling this event in order to wire up the SelectedIndexChanged event of the ComboBox embedded in the DataGridView cell.
On the bug report, Microsoft states that they will not be fixing this bug but thankfully, Debanjan1 has posted a workaround for this issue. If you simply set the CellStyle.BackColor property to the DataGridView.DefaultCellStyle.BackColor in the EditingControlShowing event, the problem goes away. This is shown below.
private void dataGridViewGLEntries_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
ComboBox cmbBx = e.Control as ComboBox;
if (cmbBx != null)
{
cmbBx.SelectedIndexChanged -= ComboBoxCell_SelectedIndexChanged;
cmbBx.SelectedIndexChanged += ComboBoxCell_SelectedIndexChanged;
// Fix the black background on the drop down menu
e.CellStyle.BackColor = this.dataGridViewGLEntries.DefaultCellStyle.BackColor;
}
}


May 4, 2011 at 1:30 am
nice
October 3, 2011 at 8:00 am
Helped me lot.. thank u…
October 14, 2011 at 3:01 am
Hi Nick,
Thanks a lot. Your solution helped me lot.
February 5, 2012 at 2:18 am
You saved my day.
February 19, 2012 at 4:01 am
it helped me a lott.Thanks a lott
April 3, 2012 at 11:06 pm
thank you thank you thank you thank you, such an annoying bug, that I couldn’t find documented anywhere else.
August 16, 2012 at 4:25 am
Cheers Nick!
January 24, 2013 at 1:15 am
Thanks