|
-
Nov 18th, 1999, 09:34 PM
#1
Thread Starter
Lively Member
Hi,
I'm new to using the Treeview control, part of the Windows Common Controls that you find in Project/Components.
When I add the Treeview control to my form I see 'Sample node' with Windows Explorer like indents, in the control in Design time. But when I run the program, there's no text in the control at all. Could someone tell me how I can make the text appear in run-time, and how I can edit the text?
Thanks!
-
Nov 18th, 1999, 09:42 PM
#2
Sure! In disign time it just shows you how the control looks like, but it is up to you to populate the control.
Here is an example:
Code:
Dim xParent As Node 'Parent Node
Dim xChild As Node 'Child Node
Dim i As Integer 'Counter for parent Nodes
Dim j As Integer 'Counter for Child nodes
With TreeView1
.LineStyle = tvwRootLines
.Indentation = 300
For i = 1 To 5
Set xParent = .Nodes.Add(, , "Parent" & i, "Parent" & i)
For j = 1 To 10
Set xChild = .Nodes.Add(xParent, tvwChild, , "Child" & i & " to node " & xParent.Text)
Next
Next
End With
Look in the MSDN library for Node object. It will tell you what it is and how to work with it.
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
[This message has been edited by Serge (edited 11-19-1999).]
-
Nov 19th, 1999, 03:37 AM
#3
Thread Starter
Lively Member
Thanks for the reply, Serge.
But I cut and paste the code you give me, and in run-time, I still can't see anything. I didn't change any properties - am I supposed to?
Here's my exact code:
Dim xParent As Node 'Parent Node
Dim xChild As Node 'Child Node
Dim i As Integer 'Counter for parent Nodes
Dim j As Integer 'Counter for Child nodes
Private Sub TreeView1_BeforeLabelEdit(Cancel As Integer)
With TreeView1
.LineStyle = tvwRootLines
.Indentation = 300
For i = 1 To 5
Set xParent = .Nodes.Add(, , "Parent" & i, "Parent" & i)
For j = 1 To 10
Set xChild = .Nodes.Add(xParent, tvwChild, , "Child" & i & " to node " & xParent.Text)
Next
Next
End With
End Sub
Am I doing something wrong?
Christophe
-
Nov 20th, 1999, 04:40 AM
#4
You pasted to the wrong event. Change it to Form_Load event.
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|