adding controls to docking manager - at runtime

Hello,

I need to add controls to form at runtime. I'm using DockingManager to arrange them. Controls are stored in List.

To add controls to form I tried to use following code:

foreach (Control control in controlList)
{
this.Controls.Add(control);
dockingManager.DockControl(
control,
control.Parent,
(DockingStyle)controlsDocking[control.Name],
control.Width);
}

The controlList is collection with Controls and dockingManager is instance of DockingManager. controlsDocking is Dictionary where key is name of Control and value DockingStyle property.

The line where I add control to dockingManager throws an ArgumentOutOfRangeException.

this is how a panel is added to collection:

panel1.Width = 200;
panel1.Parent = this;
panel1.Name = "panel1";

controlsDocking.Add(panel1.Name,DockingStyle.Left);
controlList.Add(panel1);

I tried to write those arguments in MessageBox to be sure what it returns and everything was fine, so I don't know where the problem is.
I would be glad for any help so as I could add controls to docking manager at runtime.

Thanks in advance,
J.

2 Replies

JA Jakub August 30, 2010 08:21 AM UTC

Ok, so it's working now. I guess I just missed something..


LS Lingaraj S Syncfusion Team August 30, 2010 11:11 AM UTC

Hi Jakub,

We are glad to hear that you has been solved.

Thank you for using Syncfusion products and Community Forums.

Regards,
Lingaraj S.

Loader.
Up arrow icon