I am trying to run a simple code. I have created a Form with a ComboBox (DropDownStyle = DropDown
), which is empty in the beginning, it's filled with two when the DropDown is opened.
This Form also has 2 Buttons, one of them is the proceedButton
Button sown in code.
In this block of code I am checking if the ComboBox is empty and if it, I am prompting user to select an Item from the ComboBox.
When the item is selected, I want to click proceedButton
and the Form should close, but it this action takes a second click.
private void exitButton_Click(object sender, EventArgs e)
{
exitButton.DialogResult = DialogResult.Cancel;
Debug.WriteLine("Cancel was clicked");
Close();
}
private void proceedButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(comboBox1.Text))
{
MessageBox.Show("Nothing was selected, please try again!");
}
else
{
proceedButton.DialogResult = DialogResult.OK;
Debug.WriteLine("Proceed was clicked");
}
}
Do you know why is that?