打开下拉菜单(在DataGrid视图)在一个单一的点击物品 [英] Open dropdown(in a datagrid view) items on a single click

查看:184
本文介绍了打开下拉菜单(在DataGrid视图)在一个单一的点击物品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能避免在双击一个 DropDownButton 中的 DataGridView的使用吗?现在我可以通过点击两次或更多次查看下拉 DataGridView的中的项目。第一次选择该小区,当我点击 DropDownButton 箭头第二次,它显示的列表。我怎样才能达到同样的在一个单一的点击?

How can i avoid the double click on a DropDownButton used within a DataGridView? Right now I am able to view the drop down items within the DataGridView by clicking two or more times. First time it selects the cell and second time when I click on the DropDownButton arrow, it shows the list. How can I achieve the same in a single click?

推荐答案

您可以通过订阅网格的 EditingControlShowing 事件做到这一点,并在那里类型的控制组合框

You can achieve this by subscribing for the EditingControlShowing event of the grid and there for control of type ComboBox

ComboBox ctl = e.Control as ComboBox;
ctl.Enter -= new EventHandler(ctl_Enter);
ctl.Enter += new EventHandler(ctl_Enter);

和在输入时,使用属性

void ctl_Enter(object sender, EventArgs e)
{
    (sender as ComboBox).DroppedDown = true;
}

DroppedDown表示顾名思义下拉区域是否显示与否,所以每当进入控件,这将其设置为true,无需再点击显示的项目。

DroppedDown indicates as the name suggests whether the dropdown area is shown or not, so whenever the control is entered this will set it to true and display the items without the need of further clicks.

这篇关于打开下拉菜单(在DataGrid视图)在一个单一的点击物品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆