Ali Hüseyin
Ali Hüseyin

Reputation: 13

C# open second form from a method and when this second form is closed continue

I would like to do something like that

private void button_Click(object sender, EventArgs e)
{
            open a new form
            when it is closed
            Continue from here
            .
            .
            .
}

Is it possible?

Upvotes: 0

Views: 59

Answers (2)

Luaan
Luaan

Reputation: 63722

You're looking for a modal dialog.

In Windows Forms, you can use the ShowDialog method to show a form this way:

secondForm.ShowDialog();

The basic idea is that you get a whole another UI loop running in the ShowDialog so that you have normal interactive GUI in the modal dialog, while your original form isn't accessible (mostly). When the dialog is closed, the code in the caller method continues as usual.

Upvotes: 0

kgzdev
kgzdev

Reputation: 2885

frmSecond f = new frmSecond();
f.ShowDialog() // waits until second form closed
//continue

Upvotes: 1

Related Questions