RadDock, Programmatically set DockPosition

3 posts, 1 answers
  1. Mattias Hermansson
    Mattias Hermansson avatar
    24 posts
    Member since:
    May 2010

    Posted 20 Sep 2012 Link to this post

    I've been playing around with RadDock and not been able to get my head around this control...

    Here is my scenario( bit simplyfied):

    I've got a RadDock, which I add usercontrols to:

    UserControlPlugInDemo ucpid = new UserControlPlugInDemo();
    DockPosition dockTo = DockPosition.Fill;
    this.radDock1.DockControl(ucpid, dockTo, DockType.Document);

    Then, when a user click on a button in one of these, to open a map, I add a new tab containing map with DockPosition.Right.
    This works fine.

    But next time I add a usercontrol, I want it to Fill(like merging Map with the others tabs), but it adds to the active DockWindow, either o the right or left.

    Any tip would be apreciated!
  2. Mattias Hermansson
    Mattias Hermansson avatar
    24 posts
    Member since:
    May 2010

    Posted 22 Sep 2012 Link to this post

    Sorry, after reading a little in other post and "playing" around with demos, I realized that I should avail myself of the radDock1.DockWindow() instead.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 24 Sep 2012 Link to this post

    Hello Anders,

    I am not sure if your last message would mean that you have resolved your case, but still as far as I understand your requirement, here is what you can do:

    ToolTabStrip rightHandStrip = null;
     
    private void radButton1_Click(object sender, EventArgs e)
    {
        Map1UC map1 = new Map1UC();
        ToolWindow twMap1 = new ToolWindow();
        twMap1.Controls.Add(map1);
        if (rightHandStrip == null)
        {
            this.radDock1.DockWindow(twMap1, DockPosition.Right);
            rightHandStrip = (ToolTabStrip)twMap1.Parent;
        }
        else
        {
            this.radDock1.DockWindow(twMap1, rightHandStrip, DockPosition.Fill);
        }
    }
     
    void radButton2_Click(object sender, EventArgs e)
    {
        Map2UC map2 = new Map2UC();
        ToolWindow twMap2 = new ToolWindow();
        twMap2.Controls.Add(map2);
        if (rightHandStrip == null)
        {
            this.radDock1.DockWindow(twMap2, DockPosition.Right);
            rightHandStrip = (ToolTabStrip)twMap2.Parent;
        }
        else
        {
            this.radDock1.DockWindow(twMap2, rightHandStrip, DockPosition.Fill);
        }
    }

    Basically, you should get the right ToolTabStrip the first time you need such, and then reuse it for docking the rest of the windows there. This will allow you to place all new 'map' controls in a common container positioned at right in RadDock.

    I hope this helps. Greetings,
    Nikolay
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top