Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Components & Controls > Listviews / Treeviews

Listviews / Treeviews Anything related to listview and treeview components

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-12-2008, 9:30 PM
Lek Lek is offline
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Aug 2008
Age: 23
Posts: 4
Reputation: 0
Lek is on a distinguished programming path ahead
Default how to select child node in Treeview

Let say i was created a treeview and that include some parent nodes.Each parent nodes also include some child nodes.So , i want when me double click the treeview component (Private sub..... Handles tv.DoubleClick).It will do something but the problem how i define which child node i selected?

Example :

IF e.node.index = 1 Then

do something

End If

but the e.node.index is getting the parent selected node index only ..how to get the child selected node index when i choose child node...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-12-2008, 9:38 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,329
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

The node selected is e.Node, the Node.Index property refer to the index in the Nodes collection the node belongs to.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-12-2008, 9:42 PM
Lek Lek is offline
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Aug 2008
Age: 23
Posts: 4
Reputation: 0
Lek is on a distinguished programming path ahead
Default

no ..
eg:
+Index 1 : A (parent node)
- Index 1 :A1 (child node)
- Index 2 :A2 (child node)
+Index 2 : B (Parent node)

when i want double click on A1(child node) , then will do something ,,, but impossible my e.node = 1 de? The IDE will define parent node is selected.

Last edited by Lek; 08-12-2008 at 9:50 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-13-2008, 3:56 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,329
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

Except indexes start at 0 your list is correct, so what is the problem?? Trying to explain what you are doing and want to achieve may be a better approach if you need help. You said on mouse event "do something", what is it you want to do? You have the node provided by e.Node.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-13-2008, 4:08 AM
Lek Lek is offline
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Aug 2008
Age: 23
Posts: 4
Reputation: 0
Lek is on a distinguished programming path ahead
Default

wat i want is when i double click my child node (A1) ,,then can do something.

e.g : Private sub tv_db(.......) handles Mouse.DoubleClick

If e.node = 1 Then

<- because the Parent Node A and child node A1 also same index number ,so how? ->

End if

i want double the child node to execute smth in my app.what better suggesstion to me about it ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 08-13-2008, 4:15 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,329
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

You have the node (e.Node), what else do you need??

Btw, the nodes may have same index number, but it is not the same index since they belong to different treenode collections. Get over it, it is the way it is.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-13-2008, 10:49 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jul 2008
Age: 25
Posts: 23
Reputation: 23
daPoet is on a distinguished programming path ahead
Wink

Like John H says, the
Code:
 e.node
or the [e.node.Tag] or the [e.node.Text] can be used

e.g. I use the e.node.Tag for doing specific actions like loading employee records from a form(or more like a subform) into a panel on my parent form that also has the tree.

If what John H mentioned doesnt help, try rephrasing your question. I'm also working with the tree control now and the e.node is the real trick to most "which node have i clicked and what should happen " problem


Question: Have you set the tag properties for each node in the section of your code for the tree control...

e.g.
Code:
Dim childrow As DataRow
                Dim childnode As TreeNode
                childnode = New TreeNode()
                For Each childrow In parentrow.GetChildRows("DeptToJob")
                    childnode = parentnode.Nodes.Add(childrow(0) & " " & childrow(1) & " " & childrow(2))
                    childnode.Tag = childrow("dept_id")
then I can use the
Code:
e.node.tag
to return a value to a form or a text box or a listbox

e.g. under the
Code:
treeView1_afterSelect
I can use an
Code:
textbox1.text = e.node.tag
something like that..

hope this helps

Last edited by daPoet; 08-13-2008 at 10:58 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-13-2008, 11:26 AM
Lek Lek is offline
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Aug 2008
Age: 23
Posts: 4
Reputation: 0
Lek is on a distinguished programming path ahead
Default

thx daPoet..

i got think ur suggestion be4 .but i hope can get a more better solution to solve it .
actually , use tag oso nt bad ! i hope tat work!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 3:42 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.