Hi again. I've searched a million sites and read a million threads but can't get my head round my issue. I'm creating a work directory of first names and last names (plus all other details). My treeview has only first name and last name in the listing. When a specific node is clicked/selected I want to populate textboxes with the information. All my worker names are in a dataset and it is that which populates my treeview. I'm struggling to get my head round how to select a certain node and populate textboxes.
This was adapted from an example I found which I worked with. I know I can use a row number or a node datarow but I just can't figure it out.
Any nudges in the right direction would be truely welcomed.
Code:
Private Sub LoadTreeView()
Dim letter_nodes(25) As TreeNode
Dim letter As Integer
Dim row_num As Integer
Dim data_row As DataRow
Dim record_node As TreeNode
Dim first_node As TreeNode
Dim combined_name As String
' Make the letter nodes.
treeview1.Nodes.Clear()
For letter = 0 To 25
letter_nodes(letter) = treeview1.Nodes.Add(Chr(letter + Asc("A"c)))
Next letter
' Add a TreeNode column to the table.
ds.Tables("MyDataset").Columns.Add("TreeNode", GetType(TreeNode))
' Add each name entry.
For row_num = 0 To ds.Tables("MyDataset").Rows.Count - 1
data_row = ds.Tables("MyDataset").Rows(row_num)
combined_name = data_row.Item("LASTNAME") & ", " & data_row.Item("FIRSTNAME")
letter = Asc(combined_name.Substring(0, 1).ToUpper) - Asc("A"c)
record_node = letter_nodes(letter).Nodes.Add(combined_name)
record_node.Tag = data_row
data_row.Item("TreeNode") = record_node
If row_num = 0 Then first_node = record_node
Next row_num
' Make a <New> node.
m_NewNode = treeview1.Nodes.Add("<New>")
' Select the first node.
treeview1.SelectedNode = first_node
' Accept the changes (setting the TreeNode field)
' so we don't think there are changes yet.
ds.AcceptChanges()
End Sub
Any nudges in the right direction would be truely welcomed.