selecting a treeview node programmatically

D

Dale Fye

I'm using a treeview control to display a heirarchy. I've got some code
working to add or remove nodes.

What I want to happen is that when a node is added, it will automatically
get selected and the NodeClick event should fire (to update a subform with
that nodes data).

When I delete a node, I want to automatically select one of the following,
and fire the NodeClick event for that node.
1. the nodes next sibling (if there is one)
2. previous sibling , if there is one,
3. parent, if there is one.
 
S

Stefan Hoffmann

hi Dale,

Dale said:
What I want to happen is that when a node is added, it will automatically
get selected and the NodeClick event should fire (to update a subform with
that nodes data).
Use

Dim Node As MSComctlLib.Node

Set Node = TreeView.Nodes.Add(...)
Node.Selected = True
Call Treeview_NodeClick(Node)
When I delete a node, I want to automatically select one of the following,
and fire the NodeClick event for that node.
1. the nodes next sibling (if there is one)
2. previous sibling , if there is one,
3. parent, if there is one.
Use the object browser in the VBA IDE to find the approriate methods.


mfG
--> stefan <--
 
D

Dale Fye

Stefan,

the Node.Selected = True does not highlight the selected node, but passing
the node to the NodeClick event did fill in the rest of the data
appropriatly. Any ideas how to actually highlight the newly added node?
 

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

Top