Thank you for writing.
To achieve the desired functionality, the following steps have to be considered.
1. Remove the "Close" menu items from the context menu, as explained here: http://www.telerik.com/help/winforms/dock-architecture-and-features-using-the-contextmenuservice.html
2. When adding a new HostWindow
, remove the Close
sender, Telerik.WinControls.UI.Docking.DockWindowEventArgs e)
//hide the close button
((HostWindow)e.DockWindow).DocumentButtons &= ~DocumentStripButtons.Close;
3. Even that we have remove the context menu and the close button, the user still can close a window with Ctrl+F4, so in order to prevent the windows from closing we will use the DockWindowClosing
event handler, where we will set the Cancel
property to true
4. When you want to close a window, raise a flag, which will be taken into consideration in the DockWindowClosing
sender, EventArgs e)
sender, Telerik.WinControls.UI.Docking.DockWindowCancelEventArgs e)
//cancel closing except in cases where we called it
Attached you can find a sample project, demonstrating this approach.
Let me know if I can be of further assistance.
the Telerik team