views:

506

answers:

3

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

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());
        }
    }
}
+2  A: 

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;
this. __curious_geek
+1, excellent component !
Thomas Levesque
Downloading now, will test it out, thanks!
Lasse V. Karlsen
It has the same problem, dock panels belong to a single dock target, cannot migrate from one tab to another.
Lasse V. Karlsen
I'll try the dockpanes instead of tabs.
Lasse V. Karlsen
I still don't get how I can get this working, I will edit my question with some source code for a test-program, can you take a look and see if you spot my mistake?
Lasse V. Karlsen
+1  A: 

Try Devcomponents.com

Pierreten
A: 

Try to do the following (my telerik sample):

  1. Add DockingManager from toolbox)

  2. In codebehind do the following:

DockPanel dockPanel = new DockPanel();

dockPanel.Text = "My Panel";

dockPanel.Dock = DockStyle.Fill;

//Add Dock Panel To Manager

dockingManager1.SetDocument(addProdDockPanel);

Hope this helps you out!

Regards, Raymond

Raymond Fraikin