[英]Editing Combobox item in Datagridview in C#
I have a Datagridview
in Winform. 我在Winform中有一个
Datagridview
。 One of the column is a Combobox
. 列之一是组合
Combobox
。 Is it possible to set the property such that user can enter apart from being able to select the entries from the dropdown list. 是否可以设置属性,以便用户除了可以从下拉列表中选择条目之外,还可以输入其他内容。
I was able to do it on a Combobox
item with a following changes from the properties window: 我能做到这一点的一个
Combobox
与从属性窗口中的以下修改项目:
AutoCompleteMode.SuggestAppend;
AutoCompleteSource.CustomSource;
DropDownStyle : Dropdown;
Thanks 谢谢
Something like this may Help :- 这样的事情可能会帮助:-
private void DataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (DataGridView1.CurrentCell.ColumnIndex == yourComboBoxColum)
{
ComboBox combo = e.Control as ComboBox;
if (combo == null)
return;
combo.DropDownStyle = ComboBoxStyle.DropDown;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.