Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A bug of black background for Combo box Column in DataGridView

1,352 views
Skip to first unread message

Li@discussions.microsoft.com Willie Li

unread,
May 5, 2008, 5:18:19 PM5/5/08
to
I have this problem with both VS 2005 and 2008. Each time we use this event:
private void OnEditControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
in DataGridView, the background color of the combo box column becomes
totally black, which makes the items in the combo box difficult to see. If
it does not happen in the first look at the combo box, clicking a combo box
in another row will definitely show the problem. Very easy to replicate!

I would appreciate it if anyone can tell me how to get around this
bug/problem.

Thanks!

outlaw

unread,
May 6, 2008, 6:35:59 AM5/6/08
to

Hi, i have faced the same problem & solved it by resetting the combo's
backgroud color at it's GotFocus & Dropdown event. C the following:


private void combo_SelectedIndexChanged(object sender, EventArgs e)
{
_MyController.CalculateTotal();
DataGridViewComboBoxEditingControl combo =
(DataGridViewComboBoxEditingControl)sender;
combo.SelectedIndexChanged -= new
EventHandler(combo_SelectedIndexChanged);
combo.DropDown += new EventHandler(combo_DropDown);
combo.GotFocus += new EventHandler(combo_DropDown);
}

void combo_DropDown(object sender, EventArgs e)
{
((DataGridViewComboBoxEditingControl)sender).BackColor =
Color.White;
}


Hope this will help u.


--
outlaw
------------------------------------------------------------------------
outlaw's Profile: http://forums.techarena.in/member.php?userid=48356
View this thread: http://forums.techarena.in/showthread.php?t=962443

http://forums.techarena.in

Willie Li

unread,
May 6, 2008, 11:54:01 AM5/6/08
to
That works great. I really appreciate your response. Thanks again!

VB.net@discussions.microsoft.com Captain VB.net

unread,
Jun 30, 2008, 7:25:01 AM6/30/08
to
cheeeeeeeeeeeeeeeeeeeeeeeeeeeers!

sorted.

umair....@gmail.com

unread,
Nov 27, 2013, 2:19:33 PM11/27/13
to
Works for me as well. thanks for sharing this.

Regards,
Umair
0 new messages