为DataGridView添加下拉列:
设定值:
设置单击下拉模式(否则需要点两下才能显示下拉框):
DataGridViewComboBoxColumn colShow = new DataGridViewComboBoxColumn();
colShow.Name = "spaceType";
colShow.HeaderText = "空间类型";
colShow.Width = 200;
colShow.Items.Add("选项一");
colShow.Items.Add("选项二");
colShow.Name = "spaceType";
colShow.HeaderText = "空间类型";
colShow.Width = 200;
colShow.Items.Add("选项一");
colShow.Items.Add("选项二");
colShow.DisplayIndex = 0;
dataGridView1.Columns.Insert(0, colShow);
dataGridView1.Rows[1].Cells[2].Value = "选项二";
DataGridView属性 EditMode 为 EditOnEnter
EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dgv_EditingControlShowing);
url:http://greatverve.cnblogs.com/archive/2012/02/01/DataGridViewComboBoxColumn.htmlEditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dgv_EditingControlShowing);