Completed
Last Updated: 12 Feb 2015 08:48 by ADMIN
ADMIN
George
Created on: 12 May 2014 11:35
Category: Dock
Type: Bug Report
0
FIX. RadDock - Closing the main Form should close the MdiChildren of the dock
To reproduce:

Create MDI form using RadDock by following the article: http://www.telerik.com/help/winforms/dock-mdi-mode-automatic-mdi-form-handling.html You will notice that the Closing and Closed events of the MdiForms will not be invoked.

Workaround:

Subscribe to the FormClosing event of the main Form and close all the windows manually:

void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
    this.RadDock.CloseAllWindows();
}
2 comments
ADMIN
Ivan Todorov
Posted on: 02 Feb 2015 14:09
Looking further into this, we did not manage to find a proper way for a child control to prevent its form from closing (assuming that the control might change forms at runtime). What we can do is make the CloseAllWindows return a boolean indicating if all windows were successfully closed. This will let you implement this scenario the following way:

//Form1.cs
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);
            e.Cancel = !this.radDock1.CloseAllWindows();
        }

If you need any additional customizations, you can use the GetWindows method or the DockWindows collection to check the windows that were left open after CloseAllWindows was called.
Phil Lindquist
Posted on: 12 May 2014 13:19
The work-around causes the FormClosed and FormClosing events to be invoked before the main form is closed.  That is fine.  However if you set e.Cancel = true in the FormClosing handler of one of the child windows it will not prevent the main form from closing.  That is not so good.  I'm not sure if Telerik will be able to make that work but it is highly desirable.