How to completely close and dispose of a Document window

There are docked toolbar like controls, like SolutionExplorer, Properties, etc and then there are document windows, like a source code file, etc displayed in the main content area in a tab.

No matter which window I 'close', it doesn't appear that you really close them, you just hide them.

In your Visual Studio example, you are opening some source files.  Even if user closes the tab, they don't really close.


How do I completely close and dispose of Document windows?  They should disappear from the Controls collection on the DockingManager.  





3 Replies

BR Bharathi Rajakantham Syncfusion Team January 27, 2021 03:06 PM UTC

Hi HFirst, 
 
Thanks for contacting Syncfusion Support, 
 
We have checked the reported query “How to completely close and dispose of document window ” from our end. We have achieved your requirement using SetEnableDocking() method inside DockVisibilityChanged event to remove the control from dockingManager controls collection. SetEnableDocking(control , false) removes a control from DockingManager. We can dispose the document window after disable docking using the below code. Please check the KB link and the code snippet for your reference. 
 
Code Snippet: 
 
void dockingManager1_DockVisibilityChanged(object sender, DockVisibilityChangedEventArgs arg) 
{ 
  this.dockingManager1.SetEnableDocking(arg.Control, false); 
  arg.Control.Dispose(); 
} 
 
 
Please let us know if you need any further assistance on this. We will be glad to assist you. 
 
Regards, 
Bharathi R 



HF HFirst January 27, 2021 04:45 PM UTC

I am getting an exception

Message "Object reference not set to an instance of an object." string

at Syncfusion.Windows.Forms.Tools.DockingWrapperForm.OnClosing(CancelEventArgs e)
at System.Windows.Forms.Form.WmClose(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at Syncfusion.Windows.Forms.Office2007Form.WndProc(Message& m)
at Syncfusion.Windows.Forms.Tools.DockingWrapperForm.WndProc(Message& msg)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)

I have reproduced in a sample and will submit an incident.


BR Bharathi Rajakantham Syncfusion Team January 28, 2021 04:38 PM UTC

Hi HFirst, 
 
Thanks for your update, 
 
We have checked your query and we can able to reproduce the reported issue from our side and logged a bug report on this and you can follow the # 312563 incident  for further updates. 
 
Regards, 
Bharathi R 


Loader.
Up arrow icon