Datagridviewcombobox blacks out when using editingcontrolshowing event

Source: Internet
Author: User

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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.