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.
Unfortunately, activation email could not send to your email. Please try again.

Docking Manager - replace docked control

Thread ID:

Created:

Updated:

Platform:

Replies:

90904 Oct 23,2009 11:49 AM Oct 27,2009 06:00 AM Windows Forms 1
loading
Tags: Tools
David Liddle
Asked On October 23, 2009 11:49 AM

Hi, I have docked a control using the following code below however I would then like to replace this docked control with another control.

public void DockControl(Control c, Control parent, string name, int size, DockingStyle dockingStyle)
{
m_dockingManager.BeginInit();
m_dockingManager.DockControl(c, parent, dockingStyle, size);
m_dockingManager.SetDockLabel(c, name);
m_dockingManager.SetDockAbility(c, DockAbility.None);
m_dockingManager.EndInit();
}

My attemp to replace the control was to loop through the controls array and replace it however there is only a getter not a setter method...

public void ReplaceDockControl(Control c, Control replace)
{
int index = -1;
for (int i = 0; i < m_dockingManager.ControlsArray.Length; i++)
{
if (m_dockingManager.ControlsArray[i] == c)
{
index = i;
break;
}
}

if (index > -1)
{
m_dockingManager.ControlsArray[index] = replace;
}
}

Would be very greatful for any information.

Mano J [Syncfusion]
Replied On October 27, 2009 06:00 AM

Hi David,

You can't replace a control unless you disable docking for the control.

You have to do the following in your code (ReplaceControl method) to achieve your requirement.

if (index > -1)
{
Control ctrl = dockingManager.ControlsArray[index];
// Get the properties from the controls
Control parent = ctrl.Parent.Parent;
Size size = dockingManager.GetControlSize(ctrl);
DockingStyle style = dockingManager.GetDockStyle(ctrl);
// Disable docking for the control.
dockingManager.SetEnableDocking(ctrl, false);
// dispose the control
ctrl.Dispose();
// replace with new control
DockControl(replace, parent, replace.Name, size.Width, style);
}

Thanks for using Syncfusion products.

Best Regards,
Mano

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;