Results 1 to 4 of 4

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

  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

  2. #2

    Thread Starter
    Fanatic Member ahara's Avatar
    Join Date
    Nov 2003
    Location
    Toronto
    Posts
    531
    well....I copied the code into another project and it adds only one control. Upon further investigation, I had an option checked off that I should not have. Problem resolved.
    "Knowledge is gained when different people look at the same information in different ways"

    - Louis Pasteur

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    Perhaps you want to share what "option" was that ?

  4. #4

    Thread Starter
    Fanatic Member ahara's Avatar
    Join Date
    Nov 2003
    Location
    Toronto
    Posts
    531
    It was the "Make" tab of project properties....

    "Remove information about unused Active X components" was unchecked....seems like the control was initially added, and then it somehow persisted.....when I reopened the original project, I could see it on the form at design time. I deleted it, unchecked the option (as error msg instructed to do so) and then it worked. (???)

    But it works now, so I'm
    "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