selecting a treeview node programmatically

  • Thread starter Thread starter Dale Fye
  • Start date Start date
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.
 
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 <--
 
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?
 
Back
Top