I am very new to WinTree.
My project has a UserControl tree I have been able to code the creation of the tree with static parent and child nodes.
Basicly useing:
Dim treeBatchNav As UltraTree Dim node As UltraTreeNode Dim childNode As UltraTreeNode treeBatchNav = New UltraTree With treeBatchNav
node = .Nodes.Add("Claim Node 1 TEST") 'Claim Number ' Add some child nodes for claim pages. childNode = node.Nodes.Add("Page node 1TEST") 'Claim Page childNode = node.Nodes.Add("Page node 2TEST") 'Claim Page childNode = node.Nodes.Add("Page node 3TEST") 'Claim Page childNode = node.Nodes.Add("Page node 4TEST") 'Claim Page ' Add root nodes for claim numbers node = .Nodes.Add("Claim Node 2TEST") 'Claim Number End With group.Container.Controls.Add(treeBatchNav)
Now I want to create these based off of a datasource well two if I can.
I have a tableadapter that lists claim numbers. For each claim number that is returned I want that to be a parent node.
Under each Parent node. I would like to reach out to a second tableadapter that has the pages listed.I would create a child Node for each page. (I can hard code the pages if I have too.)
So this is what I envision but can not find help on hardcoding datasources in VB.
With treeBatchNav With claimdatasource whilenot eof node = .Nodes.Add(claimnumbercolumnvalue) 'Claim Number With pagedatasource whilenot eof childNode = node.Nodes.Add(pagecolumnvalue) 'Claim Page move.next End With move.next End WithEnd With
I am guessing completely off base on how to even acomplish this. Please point me to the appropriate help documents or help me out here.
Loop through the first dataset having claim info and create parent node. Before adding the node to the tree loop through dataset having page information and add as many child nodes as the rows in the dataset. Then add the child nodes to the parent node and finally add the parent node to the tree.
Here is a sample code.
Dim wfNode As New UltraTreeNode
wfNode.Key = mvarDataRow("claimnumber")
wfNode.Text = mvarDataRow("claimnumber")
wfNode.Tag = mvarDataRow("claimnumber")
If Not pagedatasource Is Nothing AndAlso pagedatasource.Tables.Count > 0 AndAlso pagedatasource .Tables(0).Rows.Count > 0 Then
childNode = New Infragistics.Win.UltraWinTree.UltraTreeNode
childNode.Text = row.Item("pagecolumnname").Trim.ToString()
wfNode.Nodes.Add(childNode)
Next
End If
Hope it helps.
Best
S.
Thank you. This is great.
I am having a problem now where I can not get my two tables loaded into my data set.
My dataset is CA_ProdDataSet
Here is my code to load that tables.
Me.Tbl_Prod_UMCN_FlagsTableAdapter.FillByBatchID(Me.CA_ProdDataSet.tbl_Prod_UMCN_Flags, gblUserName, BatchID) 'parent node claim numbers Me.Tbl_Prod_UMCN_PagesTableAdapter.FillByAll(Me.CA_ProdDataSet.tbl_Prod_UMCN_Pages) 'child node claim pages
Here is the code I have created of your reply.
For Each mvarDataRow As DataRow In Me.CA_ProdDataSet.Tables(2).Rows Dim wfNode As New UltraTreeNode treeBatchNav.Nodes.Add(wfNode) wfNode.Key = mvarDataRow("ClaimID") wfNode.Text = mvarDataRow("ClaimID") wfNode.Tag = mvarDataRow("ClaimID") If Not Me.CA_ProdDataSet.Tables(3) Is Nothing AndAlso Me.CA_ProdDataSet.Tables(3).Rows.Count > 0 Then For Each row As DataRow In Me.CA_ProdDataSet.Tables(3).Rows childNode = New Infragistics.Win.UltraWinTree.UltraTreeNode childNode.Tag = row.Item("ClaimPages").ToString() childNode.Text = row.Item("ClaimPages").ToString() wfNode.Nodes.Add(childNode) Next End If Next
Now here is the problem if I use Me.CA_ProdDataSet.Tables(0) or (1) it is not the correct table. So its stops here: wfNode.Key = mvarDataRow("ClaimID") ... and says that ClaimID is not a column in the table XXXXX
It is two other tables I loaded when the forum loads. When I used Me.CA_ProdDataSet.Tables(2) it jumps past the node creation as if it returns no rows but does not say the data collection was empty.
You should have only one dataset with two tables one for the parent node and one for child nodes, I am not sure why you ended up with four tables.
Can you clarify me little bit?
Because in my onload of the forum I have this table loaded into the same datasource
'' From Public Sub frm_Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Tbl_MembersTableAdapter.FillByNotRemoved(Me.CA_ProdDataSet.tbl_Members)
AND I have this table loaded into the same data source.
frm_Main.Tbl_BatchsTableAdapter.FillByNotCompleted(frm_Main.CA_ProdDataSet.tbl_Batchs, assignedto, False) ''From a Module hence the frm_Main. instead of Me.
These are the two tables its loades as table 0 and 1
It was 0 row count, but that is because all along I had the variables to fill my tableadapter backwords.
Fix now thanks
Declare a local integer variable and see how many rows there in that tabels.
There should be some property tables(index).rows.count.
May be the number of rows returned from the database are zero.
Then it wont even go through For Next loop.
-Best.
Even using the table name instead of index integer it skips past "next" (does not hit: Dim wfNode As New UltraTreeNode )
Odd development here. Not sure if it will help you to understand what I messed up.
Me.CA_ProdDataset.Tables(0) is tbl_Batches
Me.CA_ProdDataset.Tables(1) is tbl_Members
Me.CA_ProdDataset.Tables(11) is tbl_Prod_UMCN_Pages ' This is my child node table.
Still dont know where my tbl_Prod_UMCN_Flags is loading too.
When I go thru tables 2 thru 10 via the code below it skips right past that Next
For Each dr As DataRow In Me.CA_ProdDataSet.Tables(2).Rows