Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This post has been useful to me also, although my case was slightly different.</p> <p>In this case avoiding <code>_currentForm.Hide();</code> works fine because the code does a form-switch. I found that the problem also originates with a MDIChild that has been hidden by a different MDIChild that is on top.</p> <p>Here's a workaround that works also in that case based on the fact that <code>Dispose</code> is always called.</p> <p>It can be done preparing something like this:</p> <pre><code>public abstract class FormExtenderClass : Form{ private bool formClosingFired = false; private bool formClosedFired = false; protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e); formClosingFired = !e.Cancel; } protected override void OnFormClosed(FormClosedEventArgs e) { base.OnFormClosed(e); formClosingFired = true; } protected override void Dispose(bool disposing) { if (!formClosingFired) OnFormClosing(new FormClosingEventArgs(CloseReason.UserClosing, false)); if (!formClosedFired) OnFormClosed(new FormClosedEventArgs(CloseReason.UserClosing)); base.Dispose(disposing); } } </code></pre> <p>Then in the code of MDIChildren just change the first row from</p> <pre><code>public partial class AutoForm : Form { </code></pre> <p>to</p> <pre><code>public partial class AutoForm : FormExtenderClass { </code></pre> <p>Consider that is in any case a worarkound. The main difference is that set <code>e.Cancel=true</code> will have no effect in the case that <code>FormClosing</code> is called from Disposed as backup.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload