Treeview and click on + to expand node

M

Marcolino

Hi I have a little problem with Treeview expand.
So I'll try to explain.

I Have one node and some subnodes like this

+Nodes1
|------Subnodes 1
|------Subnodes 2

+Nodes2
|------Subnodes 3
|------Subnodes 3

and so on....
Well if Nodes2 is selected, and I'll click on + Nodes1,in the
AfterExpand and AfterCollapse event I'll got handle for Nodes2 (the
selected one) and not for the clicked one on + to expand.
I need to get the handle for node wich i clicked + and no the selected
one.
Is there a way to do what I need?

Many Thanks
 
A

Armin Zingler

Marcolino said:
Hi I have a little problem with Treeview expand.
So I'll try to explain.

I Have one node and some subnodes like this

+Nodes1
|------Subnodes 1
|------Subnodes 2

+Nodes2
|------Subnodes 3
|------Subnodes 3

and so on....
Well if Nodes2 is selected, and I'll click on + Nodes1,in the
AfterExpand and AfterCollapse event I'll got handle for Nodes2 (the
selected one) and not for the clicked one on + to expand.
I need to get the handle for node wich i clicked + and no the
selected one.
Is there a way to do what I need?


Works for me. I always get the expanded/collapsed node. How do you
identify the node? It's in e.Node (e being one argument of the event
handler).


Armin
 
K

kimiraikkonen

Hi I have a little problem with Treeview expand.
So I'll try to explain.

I Have one node and some subnodes like this

+Nodes1
|------Subnodes 1
|------Subnodes 2

+Nodes2
|------Subnodes 3
|------Subnodes 3

and so on....
Well if Nodes2 is selected, and I'll click on + Nodes1,in the
AfterExpand and AfterCollapse event I'll got handle for Nodes2 (the
selected one) and not for the clicked one on + to expand.
I need to get the handle for node wich i clicked + and no the selected
one.
Is there a way to do what I need?

Many Thanks

Marcolino,
I tried to understand your issue and i hope adding these 2 events will
do what you want:

' Select node that's expanded
Private Sub TreeView1_AfterExpand(ByVal sender As System.Object, ByVal
e As System.Windows.Forms.TreeViewEventArgs) Handles
TreeView1.AfterExpand
TreeView1.SelectedNode = e.Node
End Sub

' Select node that's collapsed
Private Sub TreeView1_AfterCollapse(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles
TreeView1.AfterCollapse
TreeView1.SelectedNode = e.Node
End Sub

and TreeView1 is your TreeView control of course.

Hope this helps,

Onur Güzel
 
M

Marcolino

Marcolino,
I tried to understand your issue and i hope adding these 2 events will
do what you want:

' Select node that's expanded
Private Sub TreeView1_AfterExpand(ByVal sender As System.Object, ByVal
e As System.Windows.Forms.TreeViewEventArgs) Handles
TreeView1.AfterExpand
TreeView1.SelectedNode = e.Node
End Sub

' Select node that's collapsed
Private Sub TreeView1_AfterCollapse(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles
TreeView1.AfterCollapse
TreeView1.SelectedNode = e.Node
End Sub

and TreeView1 is your TreeView control of course.

Hope this helps,

Onur Güzel- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -

Hi All.
I solved. Thanks for your suggestions.

--Marco
 

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

Similar Threads


Top