Erik
Erik

Reputation: 33

Display UserControl as popup window

I have a UserControl where I have some buttons and textboxes. I was wondering how I can display that UserControl when a user clicks a button.

Upvotes: 3

Views: 10503

Answers (2)

sobby01
sobby01

Reputation: 2164

You should paste the user control on a windows form and then make it a modal window. Make a object of that form and then call object.open();

Upvotes: 0

Hans Passant
Hans Passant

Reputation: 941970

A user control cannot be a 'popup window', that requires a toplevel window. A form. You can put the user control in a form and use the form's Show() method to make it visible.

Fwiw, turning a user control into a toplevel window is technically possible with the SetTopLevel() method. It isn't worth the hassle, it won't behave like a proper one.

Upvotes: 6

Related Questions