Tomas Westerlund

Tomas Westerlund

  • NA
  • 38
  • 32.6k

My new form is being closed automatically

Nov 16 2012 4:30 AM
Hi,
This is from my mainForm:
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            //New ContactForm
            ContactForm contactForm = new ContactForm();

        }


The ContactForm opens and then I fill in some data and I press the button called Add:
        private void buttonAddContact_Click(object sender, EventArgs e)
        {
            bool isDataOk = false;

            isDataOk = contact.AddAddress(textBoxFirstName.Text,
                                            textBoxLastName.Text,
                                            textBoxPhoneHome.Text,
                                            textBoxPhoneCell.Text,
                                            textBoxEmailPrivate.Text,
                                            textBoxEmailBusiness.Text,
                                            textBoxStreet.Text,
                                            textBoxCity.Text,
                                            textBoxZipcode.Text,
                                            comboBoxCountries.Text);
        }

And now my Form closes which seems to be logical. However I want that when isDataOk = false (i.e. the input data doesn't look 100%) it should now close.

I'm not sure where and how I should put this. Can anyone please assist me in this?

Best regards,
Tomas

Answers (5)