推荐答案
我看到了同一件事,通过钩住EditingControlShowing中的Combo并为DropDown事件添加处理程序来解决该问题,在该事件中我设置了组合的背景色.即使在EditingControlShowing中设置BackColor也不起作用,因为在此之后的某个时间它会重置为黑色.
I saw the same thing and worked around it by hooking the Combo in EditingControlShowing and adding a handler for the DropDown event in which I set the combo's backcolor. Even setting the BackColor in EditingControlShowing doesn't work because it's reset to black sometime after that.
我是此控件的新手,所以我希望有一种更简单的方法来完成此操作.这似乎完全是黑客.如果您找到它,请告诉我!
I'm new to this control, so I hope there's a much easier way to accomplish this. This seems like a total hack. If you find it please let me know!
像这样的事情:(对C#发布很抱歉,但这就是我在这里使用的.我认为这还是有帮助的.)
Something like this: (Sorry about the C# posting, but that's what I'm using here. I thought this would be helpful nonetheless.)
私有 组合框 EditingCombo = 空 ;
私有 无效 grid_EditingControlShowing( 对象 发送者, DataGridViewEditingControlShowingEventArgs e)
{
EditingCombo = e.Control as ComboBox ;
如果 (EditingCombo == null ) 返回 ;
EditingCombo.DropDown + = OnEditingComboDropDown;
}
私有 void OnEditingComboDropDown( 对象 发件人, EventArgs e)
{
((( 组合框 )发送者).BackColor= Color .White;
}
private ComboBox EditingCombo = null;
private void grid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
EditingCombo = e.Control as ComboBox;
if (EditingCombo == null) return;
EditingCombo.DropDown += OnEditingComboDropDown;
}
private void OnEditingComboDropDown(object sender, EventArgs e)
{
((ComboBox)sender).BackColor = Color.White;
}
干杯,
Alex
这篇关于黑色DataGridViewComboBoxCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!