I have a datagridview in C # windows application which uses. NET 2.0. the gridview has a ComboBox cell, two textbox cells. I have written editingcontrolshowing event handler to add a selectedindexchanged event handler to the gridview ComboBox. the problem is: after one or two clicks, all cells get black background when focused. all ComboBox items when dropped down become black. when I comment out the event, this doesn't happen. (I have the same problem )/
How to solve this problem? Here is the answer.
private void dgvmodelparam_editingcontrolshowing (Object sender, datagridvieweditingcontrolshowingeventargs e)
{ComboBox cb = E. Control as ComboBox;
If (CB! = NULL)
{< br> // first remove event handler to keep from attaching multiple:
CB. selectedindexchanged-= new eventhandler (cb_selectedindexchanged);
// now attach the event handler
CB. selectedindexchanged + = new eventhandler (cb_selectedindexchanged);
CB. dropdown + = new eventhandler (cb_dropdown);
}< BR >}< br> void cb_dropdown (Object sender, eventargs e)
{< br> (ComboBox) sender ). backcolor = color. white;
}