TreeView Expand Event

  • Thread starter Thread starter g
  • Start date Start date
G

g

Hello All,

I have a treeview in my form using A2K. Everything works fine but I have to
figure out where in the code I can put to call a function when the expand (+)
was click once.

MainMenu
|___+ Add Menu
|___+ View Report

Private Sub TreeView1_NodeClick(ByVal Node As Object)

If Node.Tag = "Report0" Then
Call Report0_Click
End If
End Sub

The node click will call the function if i click once the item title but I
wanted to figure out what if I click the + beside the report item instead of
the title.

All help will greatly appreciated.

Thanks
g
 
The Expand event of the treeview control occurs when you click on the +
symbol. Note, though, that clicking on the + symbol does not cause the node
at that symbol to become the selected node; the .Selected state of all nodes
does not change when the tree is expanded (or collapsed). You can certainly
put code to call your function in the Expand event, but you need to be
careful if you're wanting that code to do something based on the selected
node; as I said, that will not necessarily be the node where you clicked to
expand the tree - if you want it to become the selected node, you will need
to do that in your code.

HTH,

Rob
 
Rob Parker said:
The Expand event of the treeview control occurs when you click on the +
symbol. Note, though, that clicking on the + symbol does not cause the node
at that symbol to become the selected node; the .Selected state of all nodes
does not change when the tree is expanded (or collapsed). You can certainly
put code to call your function in the Expand event, but you need to be
careful if you're wanting that code to do something based on the selected
node; as I said, that will not necessarily be the node where you clicked to
expand the tree - if you want it to become the selected node, you will need
to do that in your code.

HTH,

Rob
 
Thank you Rob for your comment. Could you show how or what the code needed on
this event. The reason why I need this coz once the user selected the "View
Report" additional button will show up on my form menu and that will happen
by calling the function I have. Apparently, most user use the expand/collapse
on navigating instead of the title name itself thats why Im thinking that if
I could make both way will work that will be great.

Thanks again Rob.
 
I am not sure where my replied go but I mentioned there that I appreciated
your comment on my post. By writing it down again, I need to know the code
for that event, you mentioned .selected is that part of the could? I hope you
could show some example that will work on that event(expand/collapsed). I
need this because most user use the expand/collapsed in navigating instead of
the title name on the treeview. So, If I could make them both way will call
the function that will be nice.

Thanks again Rob.
 
You'll need to keep your existing code in the NodeClick event (for users who
click on the text of the node), and add the following for the Expand event
(for users who click on the + symbol):

Private Sub TreeView1_Expand(ByVal Node As Object)
Node.Selected = True
If Node.Tag = "Report0" Then
Call Report0_Click
End If
End Sub

Rob
 
And, if they might click on the - symbol for an expanded node, use the same
code in the treeview's Collapse event.

Rob
 
Thanks Rob, that exactly what I need.

Rob Parker said:
And, if they might click on the - symbol for an expanded node, use the same
code in the treeview's Collapse event.

Rob
 

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

Back
Top