83671

.net C# windows Form Application : open popup window

Question:

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?

Answer1:

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.

Answer2:

Maybe the answer to this question will help:

<a href="https://stackoverflow.com/questions/97097/what-is-the-c-version-of-vb-nets-inputdialog" rel="nofollow">What is the C# version of VB.net’s InputDialog?</a>

Recommend

  • Android Inside Custom ListView, TextView Weight property not working
  • Java ProcessBuilder: space within quotation marks
  • How I fix a “GADInsterstitial.h” file not found… but it is in my list?
  • Why does x86 program segfault without .data section? [duplicate]
  • Detecting single one-bit streams within an integer
  • Drop-down menu is pushing the navbar down. How to avoid it?
  • Looking for datastructure that maintains a size & purges older elements in the process
  • UML diagram generator in Visual Studio 2010
  • Creating a Multi-Step Modal Using Jquery
  • Using same constraints in multiple classes
  • xcode don't localize specific strings
  • Debugging VB6 Code From Visual Studio 2010
  • How do I include a SWC in an AS2 Flash project?
  • How to add a focus style to an editable ComboBox in WPF
  • How do I superscript characters in a UIButton?
  • Debug.DrawLine not showing in the GameView
  • Swift: Switch statement fallthrough behavior
  • Android full screen on only one activity?
  • Switching to Release Build causes runtime error in Web Reference
  • Initializer list vs. initialization method
  • Control modification in presentation layer
  • Why value captured by reference in lambda is broken? [duplicate]
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Azure Cloud Service Web Role web pages do not load
  • Fetching methods from BroadcastReceiver to update UI
  • Trying to switch camera back to front but getting exception
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Adding custom controls to a full screen movie
  • jQuery tmpl and DataLink beta
  • SQL merge duplicate rows and join values that are different
  • Proper way to use connect-multiparty with express.js?
  • Free memory of cv::Mat loaded using FileStorage API
  • How to set the response of a form post action to a iframe source?
  • Angular 2 constructor injection vs direct access
  • Why joiner is not used after Sequence generator or Update statergy
  • Programmatically clearing map cache
  • Recursive/Hierarchical Query Using Postgres
  • UserPrincipal.Current returns apppool on IIS