C# – Is it possible to use ShowDialog from MdiChildForm without blocking all others MdiChildForms and MdiParent

cmdichildmdiparentshowdialogwinforms

I need to open modal form (frmD) from MdiChild (frmB) form without blocking main form (frmA) and all others opened MdiChild forms (frmC). Then i switch to frmC the frmD is hidden.

This is the similar question, but not for Mdi application.

Is there a way to open a modal dialog and only have it block the mdi child form that opened it?

Best Answer

One possible strategy is described in this article, which relies on using the .Show() method instead of .ShowDialog() to open the modal dialog and setting the MdiChild's Enabled property to false just before you call the .Show() method.

You then need to set the Enabled property of your MdiChild back to true when the dialog is closed, which means that you will need to create an event handler in your MdiChild form to handle the FormClosing event of the dialog.