In the code below, I open a form with frmContact.ShowDialog(); and then when I close the form by clicking on the OK button in the form it closes, but then it opens again because I have the frmContact.ShowDialog() in the if statement. Could this be done in some oterh way?
// Button add new customer
private void btnAdd_Click(object sender, EventArgs e)
{
ContactForm frmContact = new ContactForm();
frmContact.ShowDialog(); // Show the contact form window
if (frmContact.ShowDialog() == DialogResult.OK)
{
MessageBox.Show("OK", "Test", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
Just get rid of the first
ShowDialog.