Treeview

P

Patrick Choi

I have a treeview (version 6.0) embedded in a worksheet. After I add a node
to the structure, I wish I could have the newly added treenode highlighted
straight away so that the user could edit the label instantly, like what one
can do with Microsoft Outlook, say adding a new folder. Is there a way doing
so? Pls point me to the right direction. Thanks a lot.
 
H

Harald Staff

Hi

See if something like this works for you:

Private Sub Btn1_Click()
Dim Nodx As Node
Set Nodx = Me.Tvw1.Nodes.Add("Root", _
tvwChild, "N" & Tvw1.Nodes.Count + 1, "New node")
Nodx.EnsureVisible
Nodx.Selected = True
Tvw1.LabelEdit = tvwAutomatic
Tvw1.StartLabelEdit
Set Nodx = Nothing
End Sub

(I wrote this with VB6. Maybe the objects will need a different addressing
from Excel, but you obviously know how to do that part.)

HTH. Best wishes Harald
 
Top