I have a parent form that uses a Treeview Control and I would like to pass the node selected to a child form where the user will add update or delete the record selected using a dataset. Is there a way to pass the selected node as a parameter to the child form?
Here's my code thanks in advance!
Private Sub PopulateTreeView(ByVal inParentID As Integer, ByRef inTreeNode As TreeNode)
objConn.Open()
myReader = objCmd.ExecuteReader
' Dim Reader As OleDb.OleDbDataReader = objCmd.ExecuteReader()
While myReader.Read
For Columns = 0 To myReader.FieldCount - 1
Category = myReader.Item(Columns)
Next
On Error Resume Next
Parentnode = "AHS System Users"
Childnode = Split(Category, "")(0)
If Childnode = Nothing Then
TreeView1.Nodes.Add(Parentnode)
'LastNodeSet = Parentnode
LastNodeSet = Childnode
NodeRootRow += 1
Else
If Parentnode = LastNodeSet Then
TreeView1.Nodes(NodeRootRow).Nodes.Add(Childnode). ToString()
Else
TreeView1.Nodes.Add(Parentnode).Nodes.Add(Childnod e).ToString()
'TreeView1.Nodes.Add(Childnode).Nodes.Add(Childnod e).ToString()
LastNodeSet = Parentnode
NodeRootRow += 1
End If
End If
Parentnode = Nothing : Childnode = Nothing
End While
myReader.Close()
objConn.Close()
End Sub
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
Dim pnode = "AHS System Users"
Dim Selectnode = e.Node.Text
If e.Node.Text <> pnode Then
Dim F5 As New Form5()
F5.MdiParent = Me
F5.Show()
End If