1 Attachment(s)
Treeview added twice - why???? [resolved]
The following code adds a treeview at runtime:
VB Code:
Private WithEvents tvwMain As TreeView
Option Explicit
Private Sub Form_Load()
Set tvwMain = Controls.Add("MSComctlLib.TreeCtrl.2", "tvwMain")
With tvwMain
.Visible = True
.Top = 0
.Left = 0
.Height = 5000
End With
Debug.Print Me.Controls.Count
Debug.Print Me.Controls(0).Name
Debug.Print Me.Controls(1).Name
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 (?????)