AllTheTimeWorld.com

csharp listboxList Box Editor: Step 2, the input form

List Box Editor: Step 2, the input form

List Box Editor: Step 2, the input form

From the menu select Project, Add Windows Form. Be sure to name the form InputBox.

Build the form as shown below with buttons btnOk and btnCancel.

Write the code for form input box as shown below:

private void btnCancel_Click(object sender, EventArgs e)
{
   // On cancel erase text, then close.
   txtInput.Text = "";
   Close();
}

private void btnOk_Click(object sender, EventArgs e)
{
   // Just close, leave text as is.
   Close();
}

public TextBox getTextBox()
{
   // return txtInput by reference.
   return txtInput;
}