Popup window in winform c#

Kevin picture Kevin · May 9, 2013 · Viewed 146.7k times · Source

I'm working on a project where I need a popup window. But the thing is I also want to be able to add textboxes etc in this popup window thru the form designer.

So basically I have a button and when you click on it it will open another window that I've designed in the form designer.

I've been doing some googling but I haven't found what I needed yet so I was hoping you guys could help me!

Answer

Piotr Stapp picture Piotr Stapp · May 9, 2013

Just create another form (let's call it formPopup) using Visual Studio. In a button handler write the following code:

var formPopup = new Form();
formPopup.Show(this); // if you need non-modal window

If you need a non-modal window use: formPopup.Show();. If you need a dialog (so your code will hang on this invocation until you close the opened form) use: formPopup.ShowDialog()