DataGridView中DataGridViewComDaboBoxColumn控件点击一次即可显示下拉菜单

 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控件需要点击多次才可以显示下拉框进行修改。

DataGridView中DataGridViewComDaboBoxColumn控件点击一次即可显示下拉菜单

上一篇:css3条件判断_@supports的用法 以及 Window.CSS.supports()的使用


下一篇:windows中dllmain,创建进程和转发dll