0

我的 winforms 应用程序上有一个 datagrid 列。当用户选择特定单元格时,该单元格应变为数据绑定的组合框,并且用户可以编辑该单元格。

如何在编辑模式上显示组合框?

4

2 回答 2

1
  • 为了将单元格转换为组合框:

this.yourdatagridname.Rows[x].Cells[y] = new DataGridComboBoxCell();

其中 x,y 表示要转换的单元格

  • 为了使其可编辑:

this.yourdatagridname.Rows[x].Cells[y].ReadOnly = false;

于 2012-04-17T10:41:36.763 回答
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/

于 2012-04-15T05:07:56.160 回答