Reputation: 41832
In my project I am using two forms dialogForm
and mainForm
.
In mainForm
I am calling the instance of the dialogForm
something like this:
mainForm_Closing Event
private void mainForm_FormClosing(object sender, FormClosingEventArgs e)
{
dialogForm dg = new dialogForm();
dg.Show();
}
But in the above code, the mainForm
is closing when I press close button and showing the dialogForm
instead of even showing the mainForm
.
I know I am doing something wrong here.
PS: I edited my question very much. If someone were working with my code then here it is.
Upvotes: 0
Views: 170
Reputation: 2884
You are using dg.Show()
instead of dg.ShowDialog()
. ShowDialog()
will wait for the child dialog box to close before continuing to execute the instructions in the parent dialog box.
Return a value from the dialogForm and check if it is yes or no, and depending on that close the parent box.
Upvotes: 3