C#: DataGridViewComboBoxColumn Drop Down Menu Appears All Black

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;

12 Responses to “C#: DataGridViewComboBoxColumn Drop Down Menu Appears All Black”

  1. rahemani osama Says:


  2. arunkumar Says:

    Helped me lot.. thank u…

  3. Makbul Says:

    Hi Nick,

    Thanks a lot. Your solution helped me lot.

    • dave Says:

      You saved my day.

  4. code Says:

    it helped me a lott.Thanks a lott

  5. mellerbeck Says:

    thank you thank you thank you thank you, such an annoying bug, that I couldn’t find documented anywhere else.

  6. Sllewji Says:

    Cheers Nick!

  7. Michael Be'eri Says:

    Thanks πŸ™‚

  8. Brinda Says:

    thanks a lot πŸ™‚ its work πŸ™‚ after long time πŸ™‚

  9. Brinda Says:

    i have doubt in c#.net

  10. Adrian Says:

    Thanks Nick, saved me a lot of time and grief. All the best.

  11. Lawrence Says:

    Thank you so much for this … been annoying me for months!

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 )

Google+ photo

You are commenting using your Google+ 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

%d bloggers like this: