1 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) 2 { 3 if (e.ColumnIndex >= 0 && e.RowIndex >= 0 && dataGridView1[e.ColumnIndex, e.RowIndex] != null && !dataGridView1[e.ColumnIndex, e.RowIndex].ReadOnly) 4 { 5 DataGridViewComboBoxColumn comboboxcolum = dataGridView1.Columns[e.ColumnIndex] as DataGridViewComboBoxColumn; 6 if (comboboxcolum != null) 7 { 8 this.dataGridView1.CurrentCell = dataGridView1[e.ColumnIndex, e.RowIndex]; 9 dataGridView1.BeginEdit(true); 10 DataGridViewComboBoxEditingControl comboboxeditingcontrol = dataGridView1.EditingControl as DataGridViewComboBoxEditingControl; 11 if (comboboxeditingcontrol != null) 12 { 13 comboboxeditingcontrol.DroppedDown = true; 14 } 15 } 16 } 17 }
针对DataGridViewComDaboBoxColumn控件需要点击多次才可以显示下拉框进行修改。