By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,586 Members | 623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,586 IT Pros & Developers. It's quick & easy.

Treeview and click on + to expand node

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On May 15, 12:17 am, Marcolino <marco.pozzu...@gmail.comwrote:
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
Jun 27 '08 #2

P: n/a
"Marcolino" <ma************@gmail.comschrieb
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

Jun 27 '08 #3

P: n/a
On 14 Mag, 23:54, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On May 15, 12:17 am, Marcolino <marco.pozzu...@gmail.comwrote:


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- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -
Hi All.
I solved. Thanks for your suggestions.

--Marco
Jun 27 '08 #4

P: n/a
On May 15, 2:18 am, Marcolino <marco.pozzu...@gmail.comwrote:
On 14 Mag, 23:54, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On May 15, 12:17 am, Marcolino <marco.pozzu...@gmail.comwrote:
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- Nascondi testo tra virgolette -
- Mostra testo tra virgolette -

Hi All.
I solved. Thanks for your suggestions.

--Marco
Glad it worked!

Thanks,

Onur
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.