Adding control in runtime

yaniv

Well-known member
Joined
Apr 15, 2002
Messages
162
Location
israel
can you add control to the form during runtime.

i want to create a form that show pictures, but only if they exist in the data base.
 
i forgot the question mark in the end of the first line in my post.

have it now-
can you add control to the form during runtime?
 
Certainly.
Code:
-- In the form
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim btn As New Button()

        With btn
            .Size = New Size(90, 40)
            .Location = New Point(15, 15)
            .Text = "Testing 1 2 3"

            causes the newbtnClick procedure to fire on the click event.
            AddHandler btn.Click, AddressOf newbtnClick
        End With

        Me.Controls.Add(btn)
    End Sub

    Private Sub newbtnClick(ByVal sender As Object, ByVal e As EventArgs)
        MessageBox.Show("You clicked the button!")
    End Sub
 
Back
Top