DockTo - what do I wrong?

Docking/MDI for Windows Forms Forum

Posted 14 years ago by Michael Sabo - -privat-
Version: 2.0.93

I was continued playing with your docking windows.
How can I get following layout (created with designer) at runtime programmatically?

        private void InitializeComponent()
            this.components = new System.ComponentModel.Container();
            this.dockManager1 = new ActiproSoftware.UIStudio.Dock.DockManager(this.components);
            this.toolWindow1 = new ActiproSoftware.UIStudio.Dock.ToolWindow();
            this.toolWindowContainer1 = new ActiproSoftware.UIStudio.Dock.ToolWindowContainer();
            this.toolWindow2 = new ActiproSoftware.UIStudio.Dock.ToolWindow();
            this.toolWindowContainer2 = new ActiproSoftware.UIStudio.Dock.ToolWindowContainer();
            // dockManager1
            this.dockManager1.DocumentMdiStyle = ActiproSoftware.UIStudio.Dock.DocumentMdiStyle.ToolWindowInnerFill;
            this.dockManager1.HostContainerControl = this;
            // toolWindow1
            this.toolWindow1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.toolWindow1.DockedSize = new System.Drawing.Size(485, 438);
            this.toolWindow1.DockManager = this.dockManager1;
            this.toolWindow1.HasTitleBar = ActiproSoftware.ComponentModel.DefaultableBoolean.False;
            this.toolWindow1.Location = new System.Drawing.Point(0, 0);
            this.toolWindow1.Name = "toolWindow1";
            this.toolWindow1.Size = new System.Drawing.Size(531, 438);
            this.toolWindow1.TabIndex = 0;
            this.toolWindow1.Text = "toolWindow1";
            // toolWindowContainer1
            this.toolWindowContainer1.Dock = System.Windows.Forms.DockStyle.Left;
            this.toolWindowContainer1.DockManager = this.dockManager1;
            this.toolWindowContainer1.Location = new System.Drawing.Point(0, 0);
            this.toolWindowContainer1.Name = "toolWindowContainer1";
            this.toolWindowContainer1.Size = new System.Drawing.Size(535, 438);
            this.toolWindowContainer1.TabIndex = 8;
            // toolWindow2
            this.toolWindow2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.toolWindow2.DockedSize = new System.Drawing.Size(204, 438);
            this.toolWindow2.DockManager = this.dockManager1;
            this.toolWindow2.Location = new System.Drawing.Point(0, 25);
            this.toolWindow2.Name = "toolWindow2";
            this.toolWindow2.Size = new System.Drawing.Size(204, 413);
            this.toolWindow2.TabIndex = 0;
            this.toolWindow2.Text = "designer docking Window";
            // toolWindowContainer2
            this.toolWindowContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.toolWindowContainer2.DockManager = this.dockManager1;
            this.toolWindowContainer2.Location = new System.Drawing.Point(535, 0);
            this.toolWindowContainer2.Name = "toolWindowContainer2";
            this.toolWindowContainer2.Size = new System.Drawing.Size(204, 438);
            this.toolWindowContainer2.TabIndex = 10;
            // Form1
            this.ClientSize = new System.Drawing.Size(739, 438);
            this.IsMdiContainer = true;
            this.Name = "Form1";


        private ActiproSoftware.UIStudio.Dock.DockManager dockManager1;
        private ActiproSoftware.UIStudio.Dock.ToolWindow toolWindow1;
        private ActiproSoftware.UIStudio.Dock.ToolWindowContainer toolWindowContainer1;
        private ActiproSoftware.UIStudio.Dock.ToolWindowContainer toolWindowContainer2;
        private ActiproSoftware.UIStudio.Dock.ToolWindow toolWindow2;
Now delete "designer docking window" in designer and insert following code:

        public Form1()
            toolWindow = new ToolWindow(dockManager1, null, "Runtime docking window", -1, null);
            toolWindow.DockedSize = new Size(100, Height);
            toolWindow.DockTo(dockManager1, DockOperationType.RightInner);
Should it not produce the same behaviour?
The new window is not visible unless I resize the form manually.

Following code shows the window correctly, but the auto-hide position of the new window is left and not right:

        public Form1()
            toolWindow = new ToolWindow(dockManager1, null, "Runtime docking window", -1, null);
            toolWindow.DockedSize = new Size(100, Height);
            toolWindow.DockTo(toolWindow1, DockOperationType.RightInner);
One advantage more is that I need a reference to toolWindow1.


Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
I would move the programmatic code from the constructor to somewhere else, like OnLoad because in the constructor the controls are not properly sized and layed out yet by the system. The code in InitializeComponent works there because everything is already explictly sized and doesn't need to determine sizes dynamically. See if that helps and if you still have issues, please email us a small sample project that repros the issue. We are planning on a new maintenance release shortly so if you do still have the issue, we could use the sample project ASAP. Thanks!

Actipro Software Support

The latest build of this product (v2020.1 build 0403) was released 5 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.