JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Creating Tree Views

To create a tree view at design time, just drag a tree view control onto a Windows form, and to add nodes to it, open the Nodes property in the properties window, which displays the TreeNode editor you see in Figure 10.10.


Figure 10.10: The TreeNode Editor.

The TreeNode Editor in Figure 10.10 is working on the tree view in the TreeViews example on the CD-ROM. To start creating nodes, you use the Add Root button, which adds a top-level node. To add children to that node, you select the node and use the Add Child button. You can add text to any node in the Label box in the TreeNode editor, or double-click the text next to any node directly to edit it.

If you've added an ImageList control to the form and stored images in it, you can display those images in the tree view. Just associate an image and a selected image (which is displayed when the node is selected) with each node using the drop-down boxes in the TreeNode Editor. (In the TreeViews example, I'm using icons that come with Visual Basic, and may be found in the Common7\Graphics\icons directory).

Of course, you may want to add or remove nodes to a tree view in code. See "Creating Tree Views in Code" later in this chapter for more information.

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor