在VB.NET中加入数据集 [英] Join in Dataset in VB.NET
本文介绍了在VB.NET中加入数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,所有专家,
我在Excel文件中有2张纸,一张纸是父项"列表,另一张是子项"列表.在详细信息表中,我还输入了父项,以注意这些子项属于该父项.
我想在VB.NET中将所有父项和子项显示到DatagridView中.
我是否有可能使用Join从数据父项和子项中选择要显示在Grid中的内容?
注意:
我使用数据集来存储来自excel的数据
谢谢
TONY
Hi all experts,
I have 2 sheets in Excel File, One sheet is list of Parent Items and other is list of Child Items. In Detail Sheet, i also input the Parent Item to note that these child items are belong to this parent Items.
I want to display display all Parent and child item into DatagridView in VB.NET.
Is it possible that i use Join to select from data parent and child items to display in Grid?
Note:
I used dataset to store data from excel
Thanks
TONY
推荐答案
首先阅读Excel工作表,然后将详细信息放入数据表或数据集中
请参考此 [
Hi,
First read the Excel sheets and get the details into the datatable or dataset
refer this[^]
Now, Create the new Datatable with the consolidated columns including Parent and child.
dim tb as New DataTable();
tb.Columns.Add("P1", Type.GetType("System.String")) -- Parent
tb.Columns.Add("C1", Type.GetType("System.String")) -- Child
tb.AcceptChanges();
ForEach row as DataRow in tbParent.Rows
ForEach crow as DataRow in tbChild.Rows
If crow("P1").ToString = row("P1").ToString
DataRow r = tb.NewRow()
r("p1")= row("P1")
r("C1") = crow("C1")
tb.Rows.Add(r);
tb.AcceptChanges()
End If
Next
Next
dataGirdView1.DataSource = tb
希望对您有所帮助.
Hope it helps.
这篇关于在VB.NET中加入数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文