C# InputBox for Windows CE

Go down

C# InputBox for Windows CE Empty C# InputBox for Windows CE

ตั้งหัวข้อ by Admin on Mon Dec 01, 2014 5:08 pm

Example input box.
C# InputBox for Windows CE C%23_WinCE_InputBox

Method for this input box.
Code:
public static DialogResult InputBox(string title, string promptText, ref string value)
 {
     Form form = new Form();
     Label label = new Label();
     TextBox textBox = new TextBox();
     Button buttonOk = new Button();
     Button buttonCancel = new Button();

     form.Text = title;
     label.Text = promptText;
     textBox.Text = value;

     buttonOk.Text = "OK";
     buttonCancel.Text = "Cancel";
     buttonOk.DialogResult = DialogResult.OK;
     buttonCancel.DialogResult = DialogResult.Cancel;

     label.Top = 12;
     label.Left = 10;
     label.Width = 150;
     label.Height = 18;
     textBox.Top = 30;
     textBox.Left = 14;
     textBox.Width = 372;
     textBox.Height = 23;
     buttonOk.Top = 72;
     buttonOk.Left = 228;
     buttonOk.Width = 75;
     buttonOk.Height = 23;
     buttonCancel.Top = 72;
     buttonCancel.Left = 309;
     buttonCancel.Width = 75;
     buttonCancel.Height = 23;

     textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
     buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
     buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

     form.ClientSize = new Size(396, 107);
     form.Controls.Add(label);
     form.Controls.Add(textBox);
     form.Controls.Add(buttonOk);
     form.Controls.Add(buttonCancel);
     form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
     form.FormBorderStyle = FormBorderStyle.FixedDialog;
     form.MinimizeBox = false;
     form.MaximizeBox = false;

     DialogResult dialogResult = form.ShowDialog();
     value = textBox.Text;
     return dialogResult;
 }

Using the input box.
Code:
private void btnNewProduct_Click(object sender, EventArgs e)
 {
     string value = "";
     if (InputBox("Product", "New product name:", ref value) == DialogResult.OK)
     {
         cbProduct.Items.Add(value);
     }
 }

Admin
Admin

จำนวนข้อความ : 13
Join date : 29/01/2014

http://maithai.thai-forum.net

ขึ้นไปข้างบน Go down

ขึ้นไปข้างบน


 
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ