How to open a new window in windows form application?

.net C# windows Form Application : open popup window

  • I am using Windows Form application. I want to open a small textbox on a window to enter user's name or Email in Starting for the program. How can I achieve this?

  • Answer:

    Write one, 'tis almost trivial (creating the form and adding label, textbox and buttons) and using the VB one is perputating something that was only put in to appease the baying mob. Key method is ShowDialog() which is a method on a Form. On the form make sure you set the flags for the Ok and Cancel buttons correctly and provide a property (ideally) to allow you to read (and write if necessary) the text box You can then do something along the lines of the following: using(MyInputForm mif = new MyInputForm) { if (mif.ShowDialog() == DialogResult.OK) { dataFromDialog = mif.InputData; } else { // logic to deal with cancel } } You can do something similar in WPF, don't have an example to hand though.

Sujoy at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

Philip Wallace

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.