28 Program to insert controls at Run Time in VB.NET

Code :

Public Class Form1


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim t As New TextBox
        t.Text = "Welcome"
        t.Location = New Point(100, 100)
        t.Size = New Size(100, 100)
        t.Multiline = True
        Controls.Add(t)

        Dim b1 As New Button
        b1.Text = "Show"
        b1.Location = New Point(100, 100)
        b1.Size = New Size(400, 300)
        Controls.Add(b1)

    End Sub
End Class



Output:




Previous
Next Post »