uhu
uhu

Reputation: 1742

Winforms: Open a second modal dialog in an already open modal dialog

I have an open modal dialog and open again a modal dialog from this dialog (with ShowDialog) The problem is now that the parent modal dialog is not locked and when I click on it the second modal dialog, it moves to the background. When I close the first modal dialog, the second one still remains on the desktop. How can I prevent this behavior or what is the problem with this scenario?

Upvotes: 3

Views: 1306

Answers (1)

dthorpe
dthorpe

Reputation: 36072

Make sure you have set the dialog's Owner property. This tells WinForms/Win32 which window to disable when the new window goes modal. Do something like this:

secondDialog.Owner = firstDialog;
secondDialog.ShowDialog()

Or, try calling secondDialog.ShowDialog(firstDialog), which should set the owner chain for you.

Upvotes: 6

Related Questions