Locate the Windows Form Designer generated code region in the Designer.vb file and add your control declaration as a class member:
Private WithEvents MyButton As System.Windows.Forms.Button
In the InitializeComponent()
method, initialize the control, set its properties, and add it to the form's Controls
collection:
Me.MyButton = New System.Windows.Forms.Button()
Me.MyButton.Text = "Click Me"
Me.MyButton.Size = New System.Drawing.Size(100, 50)
Me.MyButton.Location = New System.Drawing.Point(50, 50)
Me.MyButton.Name = "MyButton"
' Add the button to the form
Me.Controls.Add(Me.MyButton)
Best Regards.
Jiachen Li
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.