如何在datagridview中显示组合框输入事件&细胞离开时可见 [英] How to display combobox in datagridview on cell enter event & visible off on Cell Leave

查看:71
本文介绍了如何在datagridview中显示组合框输入事件&细胞离开时可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据网格视图中有3列。

1 = employeeid

2 = empName

3 =说明。



每当焦点进入名为员工姓名的单元格时,组合应该准备好给员工列表。每当我选择一名员工时;它为我提供了以主表格保存的所选员工的所有记录。



Combobox应具有可编辑和自动完成的属性。

解决方案

由于你还没有真正指出你的问题是什么,这个答案只能指导你正确的方向。



第一个列,'empName',您只需要为ComboBoxColumn选择一个数据源。

请参阅 DataGridViewComboBoxColumn Class [ ^ ]



根据你的描述,它看起来像就像你想要过滤第二个ComboBoxColumn中显示的值,说明取决于'empName'列中的选择。

你可以实现这有不同的方式。



一种方法是每次选择不同的'empName'时查询数据库中的新值,然后更新ComboBoxColumn的DataSource。另外一种方法是将所有指令数据读入DataTable,将其连接到 DataView [ ^ ]或 BindingSource [ ^ ]然后每次选择不同的'empName'时更改RowFilter / Filter。

i have 3 columns into a datagridview.
1=employeeid
2=empName
3=Instructions.

whenever focus enter into cell named employee name the combo should ready to give employee list. and whenever i select an employee; it gives me all the records of that selected employee which saved in master forms.

Combobox should have property like editable and auto complete.

解决方案

As you have not really specified what your problem is, this answer can only guide you in the right direction.

For the first column, 'empName', you only need to select a data source for the ComboBoxColumn.
See DataGridViewComboBoxColumn Class[^]

From your description it looks like you want to filter the values shown in the second ComboBoxColumn, 'Instructions' depending on the selection in the 'empName' column.
You can achieve this in different ways.

One way is to query the database for new values every time a different 'empName' is selected and then update the DataSource of the ComboBoxColumn.

Another way is to read all instruction data into a DataTable, connect it to a DataView[^] or BindingSource[^] and then change the RowFilter/Filter every time a different 'empName' is selected.


这篇关于如何在datagridview中显示组合框输入事件&细胞离开时可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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