Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Popup window in winforms

Tags:

c#

winforms

popup

I have a windows form application where I show information about products and product categories in a datagridview. I would like to create a popup window so when I right click on a product and choose add to category a popup window appears and in that I show all the categories in a dropdownbox and when I click a button the product add to the category.

I want to create a popup window with a dropdownbox and a button. How do I do that in a window form application?

like image 629
Erik Avatar asked Apr 10 '11 08:04

Erik


2 Answers

You can create a regular form, and call the myPopupForm.ShowDialog() method. The ShowDialog method blocks the main form, so the user can select a category, upon which you Close() the popup window; execution will continue on the main form.

More information can be found on http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx#Y800.

like image 185
C.Evenhuis Avatar answered Oct 21 '22 19:10

C.Evenhuis


Form2 form = new Form2();

This method will be like the Message.Show method, but you can add Buttons, TextBoxes, etc. in the Designer tools.

form.ShowDialog();

This method will just bring up another form.

form.Show();
like image 20
Quantum Avatar answered Oct 21 '22 19:10

Quantum