C# InputBox for Windows CE
ไหมไทย :: C# Programming :: Mobile App
หน้า 1 จาก 1
C# InputBox for Windows CE
Example input box.
Method for this input box.
Using the input box.
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);
}
}
ไหมไทย :: C# Programming :: Mobile App
หน้า 1 จาก 1
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ
|
|