我感到恼火点击一次在datagridview中选择一行,然后再次单击以点击该行中的控件(在本例中为组合框)。只需单击一下,即可直接访问DataGridView组合框?
有没有办法配置这个东西,所有这些都可以在一次鼠标点击而不是两次完成?
我感到恼火点击一次在datagridview中选择一行,然后再次单击以点击该行中的控件(在本例中为组合框)。只需单击一下,即可直接访问DataGridView组合框?
有没有办法配置这个东西,所有这些都可以在一次鼠标点击而不是两次完成?
将DataGridView控件的EditMode属性更改为“EditOnEnter”。这将影响所有列。
试试吧,谢谢。 – 2010-08-10 00:11:13
正如我所希望的那样工作。谢谢Stuart! – 2010-08-10 00:16:40
在微软的论坛上发布了更好的解决方案。它将光标放在文本的中间,就像我想要的一样:http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/fe5d5cfb-63b6-4a69-a01c-b7bbd18ae84a – HK1 2012-10-19 15:56:45
如果要选择性地应用一键编辑某些列,可以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(e.X, e.Y);
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;
}
}
}
当然,如果你的列和他们的索引是动态的,你需要稍微修改一下。
Sooo很多datagridviews现在改变,如果我遇到一个情况下,我必须这样做,我会检查你的解决方案了! – 2010-08-10 00:25:12
我能够激活组合框和DataGridView中的编辑模式属性设置为EditOnEnter,创造EditingControlShowing事件中使用一个单一的鼠标点击下拉菜单,并添加代码打开下拉组合框中本次活动。
欲了解更多详情请查看 - http://newapputil.blogspot.in/2015/08/add-combo-box-in-cell-of-datagridview.html
您可能要检查(http://stackoverflow.com/questions/34543940/datagridviewcomboboxcolumn-doesnt-open-the-dropdown-on-first [此解决方案。]点击/ 39757746#39757746) – TaW 2016-09-28 21:18:43