Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add Controls at runtime
Message
From
22/04/2003 11:02:35
 
 
To
22/04/2003 10:49:56
Alvin Lourdes
Children and Youth Services Cluster
Toronto, Ontario, Canada
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00780136
Message ID:
00780142
Views:
15
This message has been marked as the solution to the initial question of the thread.
You can use code like this:
Dim WithEvents cmdObject As CommandButton

Private Sub Form_Load()

  Set cmdObject = Me.Controls.Add("VB.CommandButton", "cmdOne")
  cmdObject.Left = 200
  cmdObject.Top = 200
  cmdObject.Visible = True
End Sub

Private Sub cmdObject_Click()

  MsgBox "Dynamic button was clicked!"
End Sub
If you do not need to handle events of the dynamically added control, simply remove "WithEvents" keyword from its declaration.

Plamen Ivanov
MCSD .NET Early Achiever and MCAD .NET Charter Member (VB .NET/SQL Server 2000)
MCSD (VB 6.0/SQL Server 2000)

VB (.NET) - what other language do you need in the whole Universe?...

Previous
Next
Reply
Map
View

Click here to load this message in the networking platform