-
March 15th, 2000, 04:33 PM
#1
TreeView Example
Does anyone know where I can find an example of the TreeView? I need to know how to add roots and subroots, etc. And how to check the value of a seleted root. Any suggestions? Thanx
-
March 15th, 2000, 04:50 PM
#2
Re: TreeView Example
First off, try the MSDN. There's a real good example at
http://www.stlvbug.org
Click on "View Code Online" and then look toward the bottom of the page, there is a Intro Session from the February meeting that covers the Tree View control.
good luck,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
-
March 16th, 2000, 07:30 AM
#3
Re: TreeView Example
Here's some example code of populating a TreeView with 5 root nodes, 5 children and some grandchild nodes :
private Sub Form_Load()
'
Dim i as Integer
'
' Add some root level items
'
for i = 1 to 5
TreeView1.Nodes.Add , , "ROOT" & i, "Root Item " & i
next
'
' Now add some children
'
for i = 1 to 5
With TreeView1.Nodes
.Add "ROOT1", tvwChild, "ROOT1CHILD" & i, "Child Item " & i
.Add "ROOT2", tvwChild, "ROOT2CHILD" & i, "Child Item " & i
.Add "ROOT3", tvwChild, "ROOT3CHILD" & i, "Child Item " & i
.Add "ROOT4", tvwChild, "ROOT4CHILD" & i, "Child Item " & i
.Add "ROOT5", tvwChild, "ROOT5CHILD" & i, "Child Item " & i
End With
next
'
' Now Add Some Grand-Children
'
for i = 1 to 5
With TreeView1.Nodes
.Add "ROOT1CHILD2", tvwChild, , "Grand Child " & i
.Add "ROOT2CHILD2", tvwChild, , "Grand Child " & i
.Add "ROOT3CHILD2", tvwChild, , "Grand Child " & i
.Add "ROOT4CHILD2", tvwChild, , "Grand Child " & i
.Add "ROOT5CHILD2", tvwChild, , "Grand Child " & i
End With
next
End Sub
To find the value of the selected node, you can use the 'TreeView1.SelectedItem' object - that returns a 'node' pointer to the selected node.
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
-
March 16th, 2000, 11:04 PM
#4
Re: TreeView Example
Thanx! This is exactly the kind of example I needed.
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
On-Demand Webinars (sponsored)
|