Treeview question

B

Brian

Hi gurus,

I'm working with a treeview control to show a directory structure. Upon
loading, I want to preselect one of the nodes in the treeview. My code
sort-of works, the branch opens to the right node, but the node itself is
not highlighted. I'm wondering if there's something I can do to make sure a
node is highlighted when I set the SelectedNode property, or if this is just
a limitation of the Compact Framework.

Basically I'm iterating through the nodes until I find the one that matches
my path:

Private Sub FindSelectedNode(ByVal tvwNode As TreeNode)
For Each tNode As TreeNode In tvwNode.Nodes
If tNode.Tag = FilePath Then
tNode.Expand()
tvwDirectories.SelectedNode = tNode
Exit For
Else
FindSelectedNode(tNode)
End If
Next
End Sub

Thanks for any help!

Brian
 
B

Brian

Nevermind! Turned out the control didn't have focus... forcing the control
into focus fixed the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top