如何更改单元格的组合框风格DataGridViewComboBoxColumn [英] How to change cell's ComboBox style in DataGridViewComboBoxColumn
本文介绍了如何更改单元格的组合框风格DataGridViewComboBoxColumn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在DataGridViewComboBoxColumn细胞具有ComboBoxStyle的DropDownList。这意味着用户只能从下拉菜单中选择值。底层控制组合框,因此它可以有风格的下拉列表。我要如何改变DataGridViewComboBoxColumn基础组合框的样式。或者,更一般的,可我有一列的DataGridView与下拉,其中用户可以键入?
解决方案
无效dataGridView1_EditingControlShowing(对象发件人,
DataGridViewEditingControlShowingEventArgs五)
{
如果(e.Control.GetType()== typeof运算(DataGridViewComboBoxEditingControl))
{
DataGridViewComboBoxEditingControl CBO =
e.Control为DataGridViewComboBoxEditingControl;
cbo.DropDownStyle = ComboBoxStyle.DropDown;
}
}
Cells in DataGridViewComboBoxColumn have ComboBoxStyle DropDownList. It means the user can only select values from the dropdown. The underlying control is ComboBox, so it can have style DropDown. How do I change the style of the underlying combo box in DataGridViewComboBoxColumn. Or, more general, can I have a column in DataGridView with dropdown where user can type?
解决方案
void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
if (e.Control.GetType() == typeof(DataGridViewComboBoxEditingControl))
{
DataGridViewComboBoxEditingControl cbo =
e.Control as DataGridViewComboBoxEditingControl;
cbo.DropDownStyle = ComboBoxStyle.DropDown;
}
}
Problem with combobox and databound datagridview
这篇关于如何更改单元格的组合框风格DataGridViewComboBoxColumn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文