Results 1 to 4 of 4

Thread: Treeview added twice - why???? [resolved]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member ahara's Avatar
    Join Date
    Nov 2003
    Location
    Toronto
    Posts
    531

    Treeview added twice - why???? [resolved]

    The following code adds a treeview at runtime:

    VB Code:
    1. Private WithEvents tvwMain As TreeView
    2. Option Explicit
    3.  
    4.  
    5. Private Sub Form_Load()
    6.  
    7.     Set tvwMain = Controls.Add("MSComctlLib.TreeCtrl.2", "tvwMain")
    8.     With tvwMain
    9.         .Visible = True
    10.         .Top = 0
    11.         .Left = 0
    12.         .Height = 5000
    13.     End With
    14.    
    15. Debug.Print Me.Controls.Count
    16. Debug.Print Me.Controls(0).Name
    17. Debug.Print Me.Controls(1).Name
    18.  
    19.    
    20. End Sub

    When the first debug statement executes, it prints 2. The second two show the names "Treeview1" and "tvwMain" respectively. Why is the code adding two controls? The attached screen shot is the resulting form (?????)
    Attached Images Attached Images  
    Last edited by ahara; May 10th, 2004 at 09:07 AM.
    "Knowledge is gained when different people look at the same information in different ways"

    - Louis Pasteur

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width