0

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?

Austin Salonen
  • 49,173
  • 15
  • 109
  • 139
Posto
  • 7,362
  • 7
  • 44
  • 61

2 Answers2

2

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.

Murph
  • 9,985
  • 2
  • 26
  • 41
1

Maybe the answer to this question will help:

What is the C# version of VB.net’s InputDialog?

Community
  • 1
  • 1
Philip Wallace
  • 7,905
  • 3
  • 28
  • 40