|
-
Nov 21st, 2004, 10:36 PM
#1
Thread Starter
Hyperactive Member
how to check if there's a selected node in the treeview (resolved)
maybe this is simple but i'm in a hurry and i have no idea about this in treeview. I need to know how to check if there is there is selected node in the treeview.
Like in the listview is like this. lstProperty.SelectedItems.Count > 0 to determine you select 1 item on it, just don't know what is the equivalent in the treeview on selecting a node.
Thanks in advance.
Last edited by fret; Nov 24th, 2004 at 01:31 AM.
-
Nov 22nd, 2004, 03:43 AM
#2
Hyperactive Member
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.
Dr. Seuss 
-
Nov 22nd, 2004, 05:03 AM
#3
Thread Starter
Hyperactive Member
i've already tried that but seems not working.
-
Nov 22nd, 2004, 07:42 AM
#4
Hyperactive Member
Can you post the code that you're using?
The selectednode should only return a single node object rather than a collection like the listview. Treeviews only allow single selection whereas a listview provides an option to multiselect.
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.
Dr. Seuss 
-
Nov 22nd, 2004, 09:29 PM
#5
Thread Starter
Hyperactive Member
ok i figure it out lil thanks for the advice, but my problem now is this. I have a parent node called "node0" and has a child "node1". When i click a button i want "node0" to appear in a textbox seems okey, but my concern is when i select "node1" it appears in the textbox as "node1" and i want it appear as "node0" which is the parent of the "node1".
VB Code:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If TreeView1.SelectedNode.Parent.IsSelected Then 'Object reference not set to an instance of an object
TextBox1.Text = TreeView1.SelectedNode.Text
Else
TextBox1.Text = TreeView1.SelectedNode.Parent.Text 'this work if the child node is selected and it appears in the textbox the parent node
End If
End Sub
i think my code is wrong but i need some help to get in the right way.
-
Nov 23rd, 2004, 08:37 PM
#6
Thread Starter
Hyperactive Member
hey does anyone knows this?
need some help here
-
Nov 24th, 2004, 01:30 AM
#7
Thread Starter
Hyperactive Member
nevermind i figured it out by myself.
this work.
VB Code:
TreeView1.SelectedNode.Parent Is Nothing
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
|