Parent Child Help with Treelistview

Smokeywade

Member
Joined
Sep 11, 2007
Messages
22
Programming Experience
3-5
I currently have a treelistview that is populating correctly, but my problem is I need to get this nested, with another table.
I'm importing the SynapticEffect.Forms - which I got from a great example posted on codeproject -
this import is allowing me to create a treelistview object in vb.net

When I run this I get error specified cast is not valid - if I rem for chRow
the Order header populates successfully.
Here is my code:

VB.NET:
Expand Collapse Copy
Dim MyDataSet3 As New DataSet
'Get Order from Orders Header - create two columns

Dim command1 As New SqlCommand("Select *, Order_no as [openDays], Order_no as [lateDays] from LateOrders_Header_view", cnn1)

'Get Line items from Order Line
Dim command2 As New SqlCommand("Select * from LateOrders_Line_view", cnn1)
Try
cnn1.Open()

'Debug.WriteLine(cnn1.ConnectionString)
Dim DirAdapter As New SqlDataAdapter(command1)
Dim DirAdapter2 As New SqlDataAdapter(command2)

Mydataset3 = New DataSet

DirAdapter.Fill(Mydataset3, "LateOrders_Header_view")
DirAdapter2.Fill(Mydataset3, "LateOrders_Line_view")
Dim dt As DataTable = Mydataset3.Tables("LateOrders_Header_view")

Dim prow As DataRow
Dim chrow As DataRow

treeListView1.Update()
treeListView1.Items.Clear()
For Each prow In MyDataSet3.Tables("LateOrders_Header_view").Rows
Dim item As New TreeListNode '= New TreeListNode
item.SubItems.Add(prow("order_no").ToString)
item.SubItems.Add(prow("name").ToString)
item.SubItems.Add(prow("order_date").ToString)
item.SubItems.Add(prow("requested_date").ToString)
item.SubItems.Add(prow("reason").ToString)
item.SubItems.Add(prow("status").ToString)
item.SubItems.Add(prow("duedate").ToString)
item.SubItems.Add(prow("openDays").ToString)
item.SubItems.Add(prow("lateDays").ToString)
' item.SubItems.Add("")
treeListView1.Nodes.Add(item)
For Each chrow In MyDataSet3.Tables("LateOrders_Line_view").Rows
Dim chitem As New TreeListView '= New TreeListView
chitem.Nodes.Add(chrow("order_no"))
chitem.Nodes.Add(chrow("name"))
chitem.Nodes.Add(chrow("order_date"))
chitem.Nodes.Add(chrow("requested_date"))
chitem.Nodes.Add(chrow("item_id"))
chitem.Nodes.Add(chrow("purchase_class"))
treeListView1.Nodes.Add(item)
Next

Next
Any Suggestions...Thanks

Thank You
 
I figured out what the problem was i I need to change my chitem.nodes to chitem.subitems and then within that for I had to add it to item like this
item.nodes.add(chitem).

I also had to remove the treeListView1.Nodes.Add(item)
and place that at the end of the main for statement...
 
Back
Top