Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tree control node names 1

Status
Not open for further replies.

Skier44

Programmer
Aug 9, 2005
5
US
I am using an InputBox function to prompt for a name for a new node within a tree control at runtime. Is there a way to have an empty box next to the new node in the tree for the user to supply a name, similar to a new folder within Windows Explorer? Thanks
 
Try this:

Add an imagelist to a form. Add an image to the imagelist and set the key to "icon"

Form should have a treeview and a textbox (I know you said inputbox, but bare with me). Add the following code inside of your form. Start the project, type anything into the textbox, and then click the node. Voila! Your node now has text.

Private Sub Form_Load()
TreeView1.ImageList = ImageList1
Dim nodX As Node
Set nodX = TreeView1.Nodes.Add(, , , "")
nodX.Image = "icon"
End Sub

Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
TreeView1.Nodes(1).Text = Text1.Text
End Sub

I hope this helps.

Ron

Ron Repp
 
Thank you very much...this has been a big help!
 
Can you explain the purpose of the imagelist and nodX.Image? I'll have to try this out when I have time to see HOW it works. The only way I've seen this done before is to postion a text box OVER the other control, accept the input into that, then transfer it to the background control and undisplay the textbox when it loses focus. This sure looks a lot easier.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top