Microsoft KB Archive/172272

= SAMPLE: TREEVIEW.EXE Manipulating and Saving the Nodes in a TreeView Control =

Article ID: 172272

Article Last Modified on 2/24/2005

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q172272



SUMMARY
This sample illustrates how to manipulate nodes with the TreeView control. It also illustrates how to save the node information to an Access database, and then restore them. Additionally, this sample implements the drag-and-drop feature for TreeView control nodes.



MORE INFORMATION
The following file is available for download from the Microsoft Download Center:

Treeview.exe

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

The purpose of this TreeView sample is to demonstrate the basics of using and manipulating the TreeView control. This example shows how to add Nodes using the five different relationship settings of the Nodes Collection Add Method. It will also allow you to remove a selected Node or branch.

The main focus of the example is to show how to save and restore the Nodes into an Access Database. The algorithm that you use saves the Nodes in viewing order. This allows you to save and restore the TreeView control with the Nodes in the same order as they appeared to the user when the user closed the application.

The sample also shows how to drag and drop Nodes. You can also drag and drop a Node on top of a different Node so that the dragged Node is now the child of the Node it was dropped on.

For more information on the TreeView control please see Help or page 453 of the Professional Features Custom Control Reference.

To use this sample, open Treeview.vbp in the VB IDE and press the F5 key or choose Start from the Run menu.

The following files are included with this sample.

Readme.txt

Treeview.vbp

Bldtree.frm

Bldtree.frx

Keywords: kbhowto kbdownload kbtreeview kbfile kbsample KB172272

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.