如何在运行时在DatagridView的DatagridViewComboboxColumn中添加项目 [英] How to add Items in the DatagridViewComboboxColumn of DatagridView during runtime

查看:67
本文介绍了如何在运行时在DatagridView的DatagridViewComboboxColumn中添加项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的应用程序在VS2008中,并在VB.net中进行了编码.

我在一个表单上有一个datagridView(DGV).DGV包含一列DatagridViewComboboxColumn.我有另一列SrNo.

将Table1视为填充我的DatagridView的表,其中包含以下字段SrNo,Value1,Value2.

我的要求是我想从Table1填充DatagridViewComboboxColumn中的值.DatagridViewComboboxColumn的组合框应包含Table1的Value1,Value2列的值.

表1的样本数据

SrNo值1值2

1 2 3

2 4 5

由于从表1填充了datagridView中的数据,因此,表1的SrNo列的数据也填充在DGV的列之一中.

现在,我的DatagridViewComboboxColumnColumn组合框应包含各自SrNo的Value1和Value2的值.

就像我的DGV的第一个行将SrNo 1作为第一个值一样,因此SrNo 1的Value1和Value2应该添加到该行的DatagridViewComboboxColumn中.

从表1中选择不同的Value1,Value2,其中SrNo = DGV.items(0,DGV.currentcell.rowIndex).value.希望此查询可以使事情更清楚

请提出建议.

Hi,

My application is in VS2008 and coded in VB.net.

I have a datagridView(DGV) on one of my form.DGV contains a column of type DatagridViewComboboxColumn.I have another column of SrNo.

Consider Table1 to be the table from where my DatagridView is filled which contains following fields SrNo,Value1,Value2.

My requirement is i want to fill the values in my DatagridViewComboboxColumn from Table1.The DatagridViewComboboxColumn''s combobox should contain values of columns Value1,Value2 of Table1.

Sample data of Table1

SrNo Value1 Value2

1 2 3

2 4 5

As data in datagridView is filled from Table1 the data of SrNo column of Table1 is also populated in one of the column of DGV.

Now my DatagridViewComboboxColumn combobox should contain the values of Value1 and Value2 of Respective SrNo.

Like Row one of my DGV has SrNo 1 as first value,so the Value1 and Value2 of SrNo 1 should be added to the row''s DatagridViewComboboxColumn.

Select distinct Value1,Value2 From Table1 where SrNo=DGV.items(0,DGV.currentcell.rowIndex).value.Hope this Query willl make things more clear

Please Suggest.

推荐答案

看看此处 [ ^ ].可能会有帮助.
Have a look here[^]. It may help.


这篇关于如何在运行时在DatagridView的DatagridViewComboboxColumn中添加项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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