• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1096
  • Last Modified:

How to highlight node of a tree view control

In my application, I have a TreeView control that refreshes itself when data changes. After it refreshes, I would like to highlight a specific node via code. I have tried the following, but without success:

            treNovelStructure.SelectedNode = treNovelStructure.Nodes("8")

("8" is the node's name.) Not sure how to programatically highlight a node--also whether I need to select or set focus on the TreeView control.
0
evanmarshall
Asked:
evanmarshall
1 Solution
 
PaulHewsCommented:
Setting HideSelection = False will allow the selection to always be visible.
Dim node() As TreeNode = treNovelStructure.Nodes.Find("8", True)
If Not node.Length = 0 Then
    treNovelStructure.SelectedNode = node(0)
End If

Open in new window

0
 
evanmarshallAuthor Commented:
Thanks very much!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now