我的winforms应用程序上有一个datagrid列。当用户选择特定单元格时,单元格应转向数据绑定组合框,用户可以编辑单元格。
如何在editmode上显示组合框?
答案 0 :(得分:1)
您在EditingControlShowing活动中有什么?
void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
BindingSource bindingSource = this.dataGridView1.DataSource as BindingSource;
Person person = bindingSource.Current as Person;
BindingList<personType> bindingList = this.FindPersonTypes(person);
DataGridViewComboBoxEditingControl comboBox = e.Control as DataGridViewComboBoxEditingControl;
comboBox.DataSource = bindingList;
}
参考:http://www.timvw.be/2007/01/17/exploring-datagridviewcomboboxcolumn-databinding/
答案 1 :(得分:1)
this.yourdatagridname.Rows [x] .Cells [y] = new DataGridComboBoxCell();
其中x,y表示您要转换的单元格
this.yourdatagridname.Rows [x] .Cells [y] .ReadOnly = false;