1

I have a program with a main window and two floating DockContent windows (using the DockPanel-suite library). When I run the program I can dock the two floating windows together to become one floating window with two "tabs". My question is how do I do that programmatically?

Here is my code:

public Form1()
    {
        InitializeComponent();

        dp.Dock = DockStyle.Fill;
        Controls.Add(dp);

        DockContent dc1 = new DockContent();
        RichTextBox rt = new RichTextBox() { Dock = DockStyle.Fill };
        dc1.CloseButton = false;
        dc1.CloseButtonVisible = false;
        dc1.Text = "DockContent 1";
        dc1.Controls.Add(rt);
        dc1.Show(dp, DockState.Float);

        DockContent dc3 = new DockContent();
        RichTextBox rt3 = new RichTextBox() { Dock = DockStyle.Fill };
        dc3.CloseButton = false;
        dc3.CloseButtonVisible = false;
        dc3.Text = "DockContent 2";
        dc3.Controls.Add(rt3);
        dc3.Show(dp, DockState.Float);

        DockContent dc2 = new DockContent();
        RichTextBox rt2 = new RichTextBox() { Dock = DockStyle.Fill };
        dc2.Controls.Add(rt2);
        dc2.Show(dp, DockState.Document);
    }

1 Answers1

1

I found how to do this. I had to use the DockTo method of the DockContent class. Here is the code:

dc1.DockTo(dc3.Pane, DockStyle.Fill, 1);
  • +1 Good stuff, thanks for coming back with the answer. I've used this library briefly internally for our app, but my usage was limited to a single pinnable dock window. I spent most of the time making new skins for VS2012-styled tabs and strips. – Adam Houldsworth Dec 03 '13 at 11:15