GetVisibleCount Method Example

This example adds several Node objects to a TreeView control. When you click the form, the code uses the GetVisibleCount method to check how many lines are visible, and then enlarges the control to show all the objects. To try the example, place a TreeView control on a form and paste the code into the form's Declarations section. Run the example, and click the form to enlarge the control.

Private Sub Form_Load()
   Dim nodX As Node
   Dim i as Integer
   TreeView1.BorderStyle = 1 ' Show border.
   For i = 1 to 20
      Set nodX = TreeView1.Nodes.Add(,,,"Node " & CStr(i))
   Next I
   TreeView1.Height = 1500 ' TreeView is short, for comparison's sake.
End Sub

Private Sub Form_Click()
   While Treeview1.GetVisibleCount < 20 
      ' Make the treeview larger.
      TreeView1.Height = TreeView1.Height + TreeView1.Font.Size
   Wend
End Sub