DockTo - what do I wrong?

Docking/MDI for Windows Forms Forum

Posted 12 years ago by Michael Sabo - -privat-
Version: 2.0.0093
Avatar
Hello,

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();
            ((System.ComponentModel.ISupportInitialize)(this.dockManager1)).BeginInit();
            this.toolWindowContainer1.SuspendLayout();
            this.toolWindowContainer2.SuspendLayout();
            this.SuspendLayout();
            // 
            // 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.Controls.Add(this.toolWindow1);
            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.Controls.Add(this.toolWindow2);
            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.Controls.Add(this.toolWindowContainer2);
            this.Controls.Add(this.toolWindowContainer1);
            this.IsMdiContainer = true;
            this.Name = "Form1";
            ((System.ComponentModel.ISupportInitialize)(this.dockManager1)).EndInit();
            this.toolWindowContainer1.ResumeLayout(false);
            this.toolWindowContainer2.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        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()
        {
            InitializeComponent();
            toolWindow = new ToolWindow(dockManager1, null, "Runtime docking window", -1, null);
            toolWindow.DockedSize = new Size(100, Height);
            toolWindow.DockTo(dockManager1, DockOperationType.RightInner);
            toolWindow.Activate(false);
       }
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()
        {
            InitializeComponent();
            toolWindow = new ToolWindow(dockManager1, null, "Runtime docking window", -1, null);
            toolWindow.DockedSize = new Size(100, Height);
            toolWindow.DockTo(toolWindow1, DockOperationType.RightInner);
            toolWindow.Activate(false);
       }
One advantage more is that I need a reference to toolWindow1.

Thanks

Comments (1)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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 (v2018.1 build 0341) was released 6 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.