|
-
Jul 13th, 2004, 10:20 PM
#1
Thread Starter
Member
TreeView control question
Hello Guys,
How can I check if the TreeView Root is selected?
Thank you.
-
Jul 14th, 2004, 02:18 AM
#2
Does this help?
VB Code:
If TreeView1.SelectedNode Is TreeView1.Nodes(0) Then
'Do something here
End If
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Jul 14th, 2004, 05:56 PM
#3
Thread Starter
Member
Thank for the response
Its works for fist root but what if I have more then one Root or sub Root
How can I check if on of them is selected?
Thank you Again.
-
Jul 15th, 2004, 01:15 AM
#4
Hmm. I guess you'd have to check each node manually.
If the nodes are added to the tree dynamically, i would set their tag property to something identifiable. Then maybe you could make a select case.
VB Code:
Select Case TreeView1.SelecteNode.Tag.ToString
Case "WhatEver"
'Do something here
Case "WhatDoIKnow"
'Do something else here
End Select
If you are goint to manipulate an object associated with the node, then just set the object to the tag property.
Then you don't have to worry about which node is selected. You can just use the object straight away.
VB Code:
'Add Nodes similiar to this.
Dim N as New TreeNode("NodeText")
N.Tag=MyObject
TreeView1.Nodes.Add(N)
'Then all you have to do is this:
Dim M as MyObjectType
M=DirectCast(TreeView1.SelectedNode.Tag,MyObjectType)
'You will now have access to all the relevant properties and methods of the object type.
I hope I'm making some sense
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|