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

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

+3
source share
1 answer

Make sure you set the dialog owner property. This tells WinForms / Win32 that the window will be disabled when a new window becomes modal. Do something like this:

secondDialog.Owner = firstDialog;
secondDialog.ShowDialog()

Or try calling secondDialog.ShowDialog(firstDialog), which should establish a chain of owners for you.

+6
source

Source: https://habr.com/ru/post/1759180/


All Articles