User dialog with text field in winmobile

I am looking for you to have a simple user dialog like a message box that has a label and a text block in it. If there is an easy way to do this, sorry! I really do not really understand the dialogue materials.

Thanks for the help guys!

+4
source share
3 answers

Here's how to make a small custom dialog in Windows Mobile that looks like this:

alt text http://www.freeimagehosting.net/uploads/b8fb5421d6.jpg

FormBorderStyle None. , , , .

, . - BackColor SystemColors.WindowFrame, (, "" ) BackColor = SystemColors.Highlight ForeColor = SystemColor.HighlightText( ), BackColor = SystemColors.Window, . , 1- ( ).

, , (, , ):

private bool _Moving = false;
private Point _Offset;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
    _Moving = true;
    _Offset = new Point(e.X, e.Y);
}

private void Form1_MouseMove(object sender, MouseEventArgs e)
{
    if (_Moving)
    {
        Point newlocation = this.Location;
        newlocation.X += e.X - _Offset.X;
        newlocation.Y += e.Y - _Offset.Y;
        this.Location = newlocation;
    }
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
    if (_Moving)
    {
        _Moving = false;
    }
}

, , , . OK ( ) Click event:

this.DialogResult = DialogResult.OK;

, , . , , .

.

: , OK. ControlBox False, "" "X" "" , , .

+11

-, [t] , Microsoft.VisualBasic, InputBox VB :

string s = Microsoft.VisualBasic.Interaction.InputBox("prompt text",
    "title text", "default value", 0, 0);

, . , .

+1

, , , . - Microsoft.VisualBasic , InputBox, . , , .

, ( CustomDialog) (textBox1), (label1) ( "" ) .

, :

public CustomDialog(string textCaption)
{
    label1.Text = textCaption;
}

, :

public override string Text
{
    get
    {
        return textBox1.Text;
    }
}

OK :

this.DialogResult = DialogResult.OK; // this will close the form, too

To use this dialog box from your main form, you create an instance of this form, display it, verify that the OK button is clicked, and then read its Text property (which returns what you entered) as follows:

using (CustomDialog dialog = new CustomDialog("What is your name"))
{
    if (dialog.ShowDialog(this) == DialogResult.OK)
    {
        string enteredText = dialog.Text;
    }
}

You may love, but these are the basics.

0
source

All Articles