Note that there are some explanatory texts on larger screens.

plurals
  1. POFormClosing Event not called for MDI Child Form
    primarykey
    data
    text
    <p>I am trying to close a formular when opening a new one. When closing an formular, I want to process some special logic in the closing event. But the closing event is never called, neither in the FormClosing nor in the Closing event, nor in the abstract base class nor in the given manual attached event <code>form_FormClosing</code>.</p> <p>When I manual close the form by clicking the x all events are fired fine. Invoking the <code>Close()</code> method fails.</p> <p>Do you have some recmmendations to fix my issue?</p> <p><strong>MdiParent:</strong></p> <pre><code>private Form _currentForm; private void ShowForm&lt;T&gt;() where T : Form { if (_currentForm != null &amp;&amp; !_currentForm.IsDisposed) { _currentForm.Hide(); _currentForm.Close(); } var form = MdiChildren.FirstOrDefault(f =&gt; f.GetType() == typeof(T)); if (form == null) { form = _formFactory.CreateForm&lt;T&gt;(); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.FormClosing += form_FormClosing; _currentForm = form; MdiBackground.Hide(); form.Show(); } else { ActivateMdiChild(form); form.Activate(); } } void form_FormClosing(object sender, FormClosingEventArgs e) { // will not be called } </code></pre> <p><strong>Abstract generic mdi child form:</strong></p> <pre><code>public abstract partial class BaseForm&lt;TEntity&gt; : Form where TEntity : class, IEntity { protected override void OnClosing(CancelEventArgs e) { // wil not be called if (EditMode == EditModes.Editable) { MessageBox.Show(this, "Please commit or abort your changes"); e.Cancel = true; } base.OnClosing(e); } } </code></pre>
    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.
 

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