G
Guest
I am having trouble selecting a node on a tree control. The code below is
returning me the proper index, of that I'm sure. The SelectedNode statement
returns the error Object Reference Not Set To An Object. While I'm asking, I
want to not only select the node but ensure that it is visible. In other
words, I have a tree control that displays 10 entries, but the control actual
contains thirty. Maybe the one I am trying to programmatically select can
not currently be seen without moving the scroll bar. I want it to select the
right node, and make sure that the scroll bar position has it displayed. Any
help is appreciated.
Dim sKey As String
For Each sKey In hTreeKey.Keys
Dim l As Long = CLng(hTreeKey.Item(CInt(sKey)))
If l = CLng(objPin.Name) Then
Dim t As TreeNode = treeBuiltRoutes.Nodes.Item(CInt(sKey))
treeBuiltRoutes.SelectedNode = t
Exit For
End If
Next
returning me the proper index, of that I'm sure. The SelectedNode statement
returns the error Object Reference Not Set To An Object. While I'm asking, I
want to not only select the node but ensure that it is visible. In other
words, I have a tree control that displays 10 entries, but the control actual
contains thirty. Maybe the one I am trying to programmatically select can
not currently be seen without moving the scroll bar. I want it to select the
right node, and make sure that the scroll bar position has it displayed. Any
help is appreciated.
Dim sKey As String
For Each sKey In hTreeKey.Keys
Dim l As Long = CLng(hTreeKey.Item(CInt(sKey)))
If l = CLng(objPin.Name) Then
Dim t As TreeNode = treeBuiltRoutes.Nodes.Item(CInt(sKey))
treeBuiltRoutes.SelectedNode = t
Exit For
End If
Next