VISUAL BASIC_6
 

4.  Projects using Intrinsic and Professional ActiveX Controls(3)


In this lesson we will consider four projects using  the following ActiveX controls.

·         1. TreeView Control

·         2. ProgressBar Control

·         3. Drag-and-Drop Operation

·         4. WebBrowser Control

1. Project using TreeView Control:

The TreeView control is used to organise information in a hierarchial, structure.   The TreeView Control allows you to place information into an outline format similar to the one we see in Windows Explorer.   The figure 1 shows  the type of organization which we require and this is the run mode window of our project.   Drag a TreeView Control and three Command buttons in the form.   Set the caption and the name property of the buttons as shown in the figure 2 and arrange the controls accordingly. 


 
                                         Figure 1

 


                                Figure 2 

Entering the Code:

Open the Code window and enter the codes for the three command buttons as shown in the figure 1a.

 

Private Sub Command1_Click()

Dim nodx As Node

Set nodx = TreeView1.Nodes.Add(, , "R", "FoodTypes")

Set nodx = TreeView1.Nodes.Add("R", tvwChild, "Ft", "Fruits")

Set nodx = TreeView1.Nodes.Add("R", tvwChild, "Vg", "Vegetables")

Set nodx = TreeView1.Nodes.Add("R", tvwChild, "Mt", "Meat")

Set nodx = TreeView1.Nodes.Add("R", tvwChild, "Jf", "Juicy Food")

Set nodx = TreeView1.Nodes.Add("R", tvwChild, "Sf", "Salty Snacks")

nodx.EnsureVisible

End Sub

 

Private Sub Command2_Click()

Set nodx = TreeView1.Nodes.Add("Ft", tvwChild, "Ap", "Apple")

Set nodx = TreeView1.Nodes.Add("Ft", tvwChild, "Or", "Orange")

Set nodx = TreeView1.Nodes.Add("Ft", tvwChild, "Pr", "Pear")

End Sub

 

Private Sub Command3_Click()

Set nodx = TreeView1.Nodes.Add("Vg", tvwChild, "Bn", "Beans")

Set nodx = TreeView1.Nodes.Add("Vg", tvwChild, "Cr", "Carrot")

Set nodx = TreeView1.Nodes.Add("Vg", tvwChild, "Rd", "Raddish")

End Sub

 

       Figure 1a


 

Copyright © 2001 Selfonline-Education. All rights reserved.