Dock Panel component for .NET that allows docking inside tab-pages?

Lasse V. Karlsen picture Lasse V. Karlsen · May 25, 2010 · Viewed 9.7k times · Source

I want to build a user-interface that, for historical reasons, has a lot of "columns" of information. Many of these aren't relevant for all users in all cases, so I thought I'd look at dock panels to allow the users to hide or rearrange the columns according to their job scenario.

This is Winforms in .NET 3.5.

As such, I'd like the following:

  • Have tab-pages in the main form
  • Each tab-page can have dock-panels docked into them
  • Dock-panels should be movable from one tab-page to another

Example mockup http://images.vkarlsen.no/so/2902953/dock-test.png

I've tried the following component packages so far without luck:

Telerik

Allows me to dock inside a tab-page, but dock-panels can't move from one tab-page to another. When attempting to drop a floating panel onto a different tab-page than the one it came from, it appears the dock will succeed, but when dropped it is docked on its owner container.

Divelements SandDoc

Same problems as with Telerik.

DevExpress XtraBars

Same problems as with Telerik.

http://sourceforge.net/projects/dockpanelsuite/

Same problem, a dock content window can only belong to one dock panel, which means it cannot migrate from one tab to another.


Basically, does anyone know of any such component (package) that would allow me to do what I want?


Edit: Ok, I have tried getting the Sourceforge control above working, but I can't see how to make this work.

Basically, here's what I need done:

  1. I need to have multiple tab-pages (I don't need to undock these, they can be static)
  2. I need to be able to dock content into the tab-pages
  3. I need to be able to move content from one tab-page to another

If I understand the answer below that mentions this control, I should use DockPanel instead of TabControl, and DockPane instead of TabPage, but as far as I can tell, this only gives me the ability to dock and undock tab-pages, and that's not what I want.

Anyway, here's a program file, just create a Winforms project, add a reference to the .dll from the sourceforge project and paste in this code in Program.cs:

using System;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace DockTest
{
    public class DockWindow1 : DockContent
    {
        public DockWindow1()
        {
            TabText = "Dock-window #1";

            DockPanel panel = new DockPanel();
            panel.Dock = DockStyle.Fill;
            Controls.Add(panel);

            // tried this related to the exceptions
            // this.DockPanel = panel;
        }
    }

    public class DockWindow2 : DockContent
    {
        public DockWindow2()
        {
            TabText = "Dock-window #2";

            ListBox lb = new ListBox();
            Controls.Add(lb);
            lb.Dock = DockStyle.Fill;
            lb.Items.Add("Listbox");
        }
    }

    public class MainForm : Form
    {
        public MainForm()
        {
            DockPanel panel = new DockPanel();
            panel.Dock = DockStyle.Fill;
            panel.DocumentStyle = DocumentStyle.DockingWindow;
            Controls.Add(panel);

            // exceptions here
            DockPane dp = panel.DockPaneFactory.CreateDockPane(
                new DockWindow1(), DockState.Document, true);
            dp.AllowDockDragAndDrop = true;
            dp.AllowDrop = true;

            DockWindow1 w1 = new DockWindow1();
            w1.Show(panel);

            DockWindow2 w2 = new DockWindow2();
            w2.Show(panel);
        }
    }

    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.Run(new MainForm());
        }
    }
}

Answer

this. __curious_geek picture this. __curious_geek · May 25, 2010

Try this.

http://sourceforge.net/projects/dockpanelsuite/

EDIT

You can try DockPane instead of Tabs if at all possible. DockPane will let you move elements from one Pane to another.

1.DockPanel replaces TabControl
2.DockPane replaces TabPages

DockPane dp = dockPanel.DockPaneFactory.CreateDockPane(new DockForm(), DockState.Document, true);
dp.AllowDockDragAndDrop = true;
dp.AllowDrop = true;