一键直接访问DataGridViewcombobox?

单击一次以在datagridview中选择一行,然后再次单击以单击该行中的控件(在本例中为combobox),我感到很恼火。

有没有办法配置这个东西,所有这一切都可以通过一次鼠标点击而不是两个?

将DataGridView控件的EditMode属性更改为“EditOnEnter”。 这会影响所有列。

如果要有选择地将单击编辑应用于某些列,可以在MouseDown事件期间切换当前单元格以消除要编辑的单击:

// Subscribe to DataGridView.MouseDown when convenient this.dataGridView.MouseDown += this.HandleDataGridViewMouseDown; private void HandleDataGridViewMouseDown(object sender, MouseEventArgs e) { // See where the click is occurring DataGridView.HitTestInfo info = this.dataGridView.HitTest(eX, eY); if (info.Type == DataGridViewHitTestType.Cell) { switch (info.ColumnIndex) { // Add and remove case statements as necessary depending on // which columns have ComboBoxes in them. case 1: // Column index 1 case 2: // Column index 2 this.dataGridView.CurrentCell = this.dataGridView.Rows[info.RowIndex].Cells[info.ColumnIndex]; break; default: break; } } } 

当然,如果您的列及其索引是动态的,则需要稍微修改一下。

通过将DataGridView的EditMode属性设置为EditOnEnter并创建EditingControlShowing事件并添加代码以在此事件中下拉combobox,我能够通过单击鼠标来激活combobox并将其下拉。

有关详细信息,请查看 – http://newapputil.blogspot.in/2015/08/add-combo-box-in-cell-of-datagridview.html