Renaud is Not Bill Gates
Renaud is Not Bill Gates

Reputation: 2074

add a user control to a form

Hi there I have a user control in my project and I want to add this user control to a form when I click on a button.

This is the code I wrote:

Using GstAbonnement As New GestionAbonnement() With {.Dock = DockStyle.Fill}
            Panel1.Controls.Add(GstAbonnement)
End Using

The problem is when I click on the button nothing happens

Upvotes: 0

Views: 5449

Answers (1)

Sylens
Sylens

Reputation: 1177

try this

Dim GstAbonnement As New GestionAbonnement()
GstAbonnement.Dock = DockStyle.Fill
Panel1.Controls.Add(GstAbonnement)

After you are done with the control, dispose it

GstAbonnement.Dispose()

Upvotes: 2

Related Questions