Does C# have a equivelant VB.NET InputBox()?
.NET doesn't provide a InputBox(), but you could make one yourself:
Usage:
I found that one using the good ol' Google. Hope it helps!
public static InputBoxResult Show(string prompt, string title, string defaultResponse, InputBoxValidatingHandler validator, int xpos, int ypos) { using (InputBox form = new InputBox()) { form.labelPrompt.Text = prompt; form.Text = title; form.textBoxText.Text = defaultResponse; if (xpos >= 0 && ypos >= 0) { form.StartPosition = FormStartPosition.Manual; form.Left = xpos; form.Top = ypos; } form.Validator = validator; DialogResult result = form.ShowDialog(); InputBoxResult retval = new InputBoxResult(); if (result == DialogResult.OK) { retval.Text = form.textBoxText.Text; retval.OK = true; } return retval; }}public static InputBoxResult Show(string prompt, string title, string defaultText, InputBoxValidatingHandler validator) { return Show(prompt, title, defaultText, validator, -1, -1);}
Usage:
private void buttonTest_Click(object sender, System.EventArgs e) { InputBoxResult result = InputBox.Show("Test prompt:", "Some title", "Default text", null); if (result.OK) { textBox1.Text = result.Text; }}
I found that one using the good ol' Google. Hope it helps!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement