当前位置: 动力学知识库 > 问答 > 编程问答 >

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;
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: