hey,
i've made a app. it has a addon part where the user can add buttons here and there and they can open external app's.
how do i set it up so i can create controls on the fly?
Printable View
hey,
i've made a app. it has a addon part where the user can add buttons here and there and they can open external app's.
how do i set it up so i can create controls on the fly?
Dim blah as New System.Windows.Forms.Button
blah.Left = anumber
blah.Top = anumber
blah.Text = 'Click Me"
blah.Visible = True
Form1.Controls.Add(blah)
This creates new instance of button object and add it to your form at runtime . Just provide some specific info related to location and size as you need .
VB Code:
Dim Butn As New System.Windows.Forms.Button() Butn.Size = New System.Drawing.Size(150, 30) Butn.Name = "Button1" Butn.Text = "BUTTON1" Me.Controls.Add(Butn)
Mix and match both mine and Pirates code. :D I showed positioning of the control, he covered size.
thanx
what about events?
If you make controls dynamically at run time, say it could be between three to thirty textboxes, how do you code to process the unique events?
In this case you can use Delegates and WithEvents .