简体   繁体   中英

c# input text in a popup or similar box

I need my user to enter the date of the transaction during the process of parameterizing the sql insert query. I thought of a popup window with a textbox, returning the date, as string maybe, but I faced many issues and I guess there is an easier way. Also I have to call this code many times, because each transaction have different parameters, but the date is always there. There is an input box I saw, but couln't really understand how it works. Thank you for your help. it's in C#.

One thing you can do, is reference Visual Basic's Input Box. You can do this by referencing it at the top;

using Microsoft.VisualBasic.Interaction;

and then accessing the input box object like so;

string yourReturnedValue = Microsoft.VisualBasic.Interaction.InputBox("Question", "Title", "Default", 0, 0);

This will prompt the user a MessageBox type box, but with an input field which you can assign to the variable, as shown in the example above - "yourReturnedValue"

More information can be found here; http://msdn.microsoft.com/en-us/library/6z0ak68w(v=vs.80).aspx

Try this : InputBox

I'm using the InputBox in quite a few places. Here an example:

InputBoxResult InputDate = InputBox.Show("Please enter a Date:", 
                                         "Input Date",
                                         DateTime.Today.ToString("dd.MM.yyyy"));

if (InputWorkspaceName.ReturnCode == DialogResult.OK)
{
    RequestData(InputDate.Text);
}

Here Is the Result Class

public class InputBoxResult 
{
    public DialogResult ReturnCode;
    public string Text;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM