DataGridView + ComboBox [英] DataGridView + ComboBox

查看:97
本文介绍了DataGridView + ComboBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在DGV中使用DataGridViewComboBoxColumn但是你知道用这个方法创建的组合框允许我们只从ComboBox(DropDownList)中选择值,我们不能输入组合框中不存在的值。

i tried to use a DataGridViewComboBoxColumn in a DGV but as you know the combobox created with this method allows us to choose values only from the ComboBox (DropDownList) we can not type values witch does not exist in the Combobox Items.

所以我使用DataGridViewTexBoxColumn,我捕获CellBeginEdit以在已编辑的单元格中显示ComboBox

so i use a DataGridViewTexBoxColumn, and i capture the CellBeginEdit to show a ComboBox within the edited cell 

当CellEndEdit触发时,我删除了ComboBox。

and when CellEndEdit fires, i remove the ComboBox.

直到现在一切都还好

我的问题是:

当显示组合框时,我必须再次点击它以获得keyboeard焦点在它上面(就像DGV仍然有键盘焦点,即使显示组合框,所以我必须点击其他时间将键盘焦点设置在组合上)

when the combobox is shown, i have to click on it an other time to gain the keyboeard focus on it (it's like the DGV still have the keybord focus, even if the combobox is shown, so i have to click an other time to set the keyboard focus on the Combo)  

当我第一次显示时,有一种方法可以将键盘焦点直接设置在Combobox上,这样当我输入ComboBox文本时也会发生变化。

is there a way to set the keyboard focus directely on the Combobox when it's shown the first time so when i type the ComboBox text changes too.

谢谢。

推荐答案

我还没有这样做,所以我不确定,但你不能用它MyCombo.Focus()方法?


这篇关于DataGridView + ComboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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