Messagebox with input field

Is it possible to show a (pop-up) message box with an input field in it, possibly a text field? Is there a language or framework somewhere?

+56
c #
May 29 '12 at 10:57
source share
2 answers

You can reference Microsoft.VisualBasic.dll .

Then use the code below.

 Microsoft.VisualBasic.Interaction.InputBox("Question?","Title","Default Text"); 

Also, adding a using directive that allows for shorter syntax in your code (which I personally would prefer).

 using Microsoft.VisualBasic; ... Interaction.InputBox("Question?","Title","Default Text"); 

Or you can do what Pranai Rana offers, what I would do too ...

+80
May 29 '12 at 10:58
source share
— -

You can do this by creating a form and displaying it using ShowDialogBox ....

Form.ShowDialog Method - Displays the form as a modal dialog box.

Example:

 public void ShowMyDialogBox() { Form2 testDialog = new Form2(); // Show testDialog as a modal dialog and determine if DialogResult = OK. if (testDialog.ShowDialog(this) == DialogResult.OK) { // Read the contents of testDialog TextBox. this.txtResult.Text = testDialog.TextBox1.Text; } else { this.txtResult.Text = "Cancelled"; } testDialog.Dispose(); } 
+49
May 29 '12 at 10:59 a.m.
source share



All Articles