Here's a bit of code:
On a Form (InputBox.cs) which contains a textbox (textBox1) and two buttons
(button1 and button2). Drop this in as the constructor:
public InputBox()
{
InitializeComponent();
button1.Text = "OK";
button1.DialogResult = DialogResult.OK;
button2.Text = "Cancel";
button2.DialogResult = DialogResult.Cancel;
textBox1.Text = "";
}
public InputBox(string Caption, string DefaultValue) : this()
{
this.Text = Caption;
textBox1.Text = DefaultValue;
}
// and an accessor to get the value
public string Value
{
get { return textBox1.Text; }
}
Now call the thing like this... (from the main thread - a button click on
the main form in my case)
private void button1_Click(object sender, System.EventArgs e)
{
InputBox input = new InputBox("Enter your zip code", "85048");
if (input.ShowDialog() == DialogResult.OK)
MessageBox.Show(input.Value);
input.Dispose();
}
HTH;
Eric Cadwell
http://www.origincontrols.com