ADT/ODE: How to Remove All Nodes from TreeView ControlID: Q172286
|
Advanced: Requires expert coding, interoperability, and multi-user skills.
The Microsoft TreeView control version 5.0 ships with Microsoft Office 97
Developer Edition.
Use the Clear method to remove all nodes in a TreeView control.
This article assumes that you are familiar with Visual Basic for
Applications and with creating Microsoft Access applications using the
programming tools provided with Microsoft Access. For more information
about Visual Basic for Applications, please refer to the "Building
Applications with Microsoft Access 97" manual.
The following example demonstrates creating a TreeView control, adding
nodes, and then removing the nodes:
TreeView Control
----------------
Name: tvcExample
Width: 2
Height: 2
Command Button
----------------------
Name: btnFillTreeView
Caption: Fill TreeView
Width: 1"
Height: .25"
Private Sub btnFillTreeView_Click()
Dim nodX As Node ' Declare Node variable.
With Me!tvcExample
' Set Treeview control properties.
.LineStyle = tvwRootLines ' Linestyle 1
' Add Node objects
' First node with 'Root1' as text.
Set nodX = .Nodes.Add(, , "r1", "Root1")
' Second node on root with 'Root2' as text
Set nodX = .Nodes.Add(, , "r2", "Root2")
' This next node is a child of Node 1 ("Root").
Set nodX = .Nodes.Add("r1", tvwChild, "child1", "Child")
End With
End Sub
Command Button
-----------------------
Name: btnDeleteAllNodes
Caption: Clear TreeView
Width: .25"
Height: 1"
Private Sub btnDeleteAllNodes_Click()
Me!tvcExample.Nodes.Clear
End Sub
For more information about nodes in the TreeView control, search the Help Index for "node object."
Additional query words: basic delete
Keywords : kbprg OdeGen
Version : 7.0,97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 20, 1999