We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Removing items from the DockingManager Control Array

Hi Guys,

Can you provide an example that shows how I can remove a control from the DockingManager so that the resource is released? When I close a control that is hosted by the docking manager, it remains part of the ControlsArray indefinately which is suboptimal.

Regards

Matt

8 Replies

VS Vallarasu S Syncfusion Team July 30, 2010 10:07 AM UTC

Hi Matt,

Thanks for your interest in Syncfusion products,

Closing a window from the DockingManager sets the Windows dockVisibility to false, so that the window can be displayed again,
if you need to release the control from the DockingManager you can use SetEnableDockgin method of the docking manager as follows,


// removes and releases the control from the DockingMangaer
this.dockingManager1.SetEnableDocking(this.GroupBar1, false);

// releases the custom caption buttons that are used
BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic;
FieldInfo fieldInfo = dockingManager1.GetType().GetField("htCustomCaptionButtons", bindingFlags);
if (fieldInfo != null)
{
Hashtable tab = fieldInfo.GetValue(dockingManager1) as Hashtable;
tab.Remove(this.GroupBar1);
}


Refer the sample at the following link that demonstrates the above,

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=DockingManager-541423378.zip

Please let us know if you have concerns on this.


Regards
Vallarasu S.


MS Matt Speller August 3, 2010 11:11 AM UTC

Thank you very much for getting back to me. The method SetEnableDocking in the example works as expected but when implemented in our soultion I get exceptions thrown. I would like to confirm if the error is associated to the error refered to in this post - https://www.syncfusion.com/support/forums/tools-windows/15501/Docking-Manger-doesnot-remove-the-Control-permenently.

This is the line of code the causes the error -

private void OnDockVisibilityChanging(object sender, DockVisibilityChangingEventArgs arg)
{
Control smartPart = arg.Control;
this.dockManager.SetEnableDocking(smartPart, false);
}

Here is the call stack of the Syncfusion error generated (no custom code at all)

System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.Windows.Forms.Tools.DockHostController.CloseController()
at Syncfusion.Windows.Forms.Tools.DockHostController.set_DockVisibility(Boolean value)
at Syncfusion.Windows.Forms.Tools.DockHostController.HandleMouseUpImp(MouseButtons button, Point pt)
at Syncfusion.Windows.Forms.Tools.DockHost.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at Syncfusion.Windows.Forms.Tools.DockHost.WndProc(Message& msg)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



MS Matt Speller August 3, 2010 12:52 PM UTC

Sorry - I Forgot to mention we are currently on version 7.102.0.30


LE Lokanath E Syncfusion Team August 4, 2010 11:03 AM UTC

Hi Matt,

Thanks for using Syncfusion products.

The forum post you have specified is about the same behavior. You can use DockVisibilityChanged event instead of DockVisibilityChanging event to release the control from the DockingManager using SetEnableDocking method.

Refer the sample at the following link. We hope it might help you.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=DockingCaption1944784865.zip

Please let us know if you have any queries.

Regards,
Lokanath.E



MS Matt Speller August 9, 2010 02:43 PM UTC

Thanks for the update, using the Changed method intstead of the Changing method I submitted, I still got the same exception thrown. Back to my original question, is this the same issue suggested in the other post I mentioned and is this an area that has been fixed/modified since version 7?


LE Lokanath E Syncfusion Team August 10, 2010 11:35 AM UTC

Hi Matt,

Thanks for your interest in Syncfusion products.

We deeply regret for the inconvenience. We are afraid that we could not reproduce the issue while using DockVisibilityChanged event to remove the reference from DockingManager with your mentioned version. Could you please try to reproduce the issue in previous provided sample or send us minimal sample that could be helpful for us to analyze the issue and provide a better solution.

We have attached a video file at the following link which I tried from previous provided sample.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=DockVisibilityChanged_video-1019287221.zip

Please let us know if you have any concern.

Regards,
Lokanath.E


MS Matt Speller August 17, 2010 11:43 AM UTC

Upgrading to 8.2 solved my issues, so I did just that.

Thanks


LS Lingaraj S Syncfusion Team August 18, 2010 04:07 AM UTC

Hi Matt,

Thank you for the update and your contribution in Syncfusion Community Forums.

Regards,
Lingaraj S.

Loader.
Live Chat Icon For mobile
Up arrow icon