I am new to VB.net so I am not sure if there is a good way to do this or not but here is my problem. I have created a form with a TreeView control on it. When the user selects a node from the treeview I would like to use the AFTER_SELECT method to bring up a new form if possible containing a dataset for the record selected. OR as an alternative I would like to bring up a dataset for that record selected on the same form. I have succeeding in capturing the node selected (e.node.text) however I can't use that variable to load the data set using an SQL statement or can I?????. Is there any easy way to do this????
Here is a sample of my code:
thanks in advance
Dim qryString1 As String = "SELECT * FROM ClientTab WHERE CLNAME LIKE '" & Selectnode & "%'"
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 = "Client"
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 = "Client"
Dim Selectnode As String
Selectnode = e.Node.Text
If e.Node.Text <> pnode Then
objConn.Open()
OLDAdapter.Fill(AHSCLIENTFILEDataSet)
objConn.Close()
' Dim F3 As New Form3
' Dim childform As New Form3
' childform = New Form3()
' F3.MdiParent = Me
' childform.Show()
End If
End Sub