Rob Smyth

Tuesday 13 November 2007

VS Like Docking Framework - DockPanel Suite

I've been using the DockPanel Suite framework in a little home application I'm working on. I like it. It provides Visual Studio like window docking for very little effort.

It is an open source project on SourceForge. It could do with better C# 'Getting Started' guide but it is simple to use and the separately downloaded VB documentation gives enough clues to get started. Lot of 'here are what you can achieve stuff', but a bit short on 'here are examples to get you started'.

To use, place a DockPanel filling your window client. This will be the parent for all docking windows. Or if like me you like the programmatic injection approach:


private DockPanel CreateDockPanel()
{
DockPanel dockPanel = new DockPanel();
dockPanel.ActiveAutoHideContent = null;
dockPanel.Dock = DockStyle.Fill;
dockPanel.Font = new Font("Tahoma", 14F, FontStyle.Regular, GraphicsUnit.World);
dockPanel.Name = "dockPanel";

return dockPanel;
}

:

MainForm mainForm = new MainForm(mainFormController, dockPanel);

:

public MainForm(IMainFormController controller, Control dockPanel) : this()
{
this.controller = controller;
Controls.Add(dockPanel);
dockPanel.BringToFront();
}

Your docking windows must all be UserControls that inherit from DockContent (which inherits from UserControl).

An example from some of my code adding a docking window:

propertiesView = new PropertiesView();
propertiesView.ShowHint = DockState.DockLeft;
propertiesView.Show(dockPanel);

A gotcha I found was when passing the DockPanel be sure to reference it as a DockPanel type and not just as a Control. It seems to make a difference.

10 comments:

Nathan said...

no one seems to have any sample code for DockPanel Suite. i cannot seem to get the windows to show and dock properly with the DockPanel...sample code would be a life-saver.

Thanks!

Rob Smyth said...

Hi Nathan,

Yea I had the same problem, the documentation is limited. I have a couple of open source projects using the framework that may be of help to you.

I'm currently playing with developing a library of dockable controls to enable programmatic UI creation with automatic layout. Far from complete but and example for you. You will find the framework 'NoeticTools.Docking' on my NoeticTools google project. This framework is being using for the simulator part of my (unfinished) VicFireReader project.

Check those out to see if they give you the code fragments you need. If not, I can whip up an example for you.

Rob

Nathan said...

yeah an example would be great. Your noetic tools was helpful and I worked through some of my issues, but I still can't get it to run properly.

Thanks so much!

Rob Smyth said...

Hi Nathan,

No problems. Tonight I grabed the VS project for my other Dock Panel Suite blog entry, cleaned it up a bit, and created a Google project for it. You can grab the code here.

Creating a Goolge Project allows me to update the code to give more/better examples. Let me know if there is anything missing or detail you would like.

Rob Smyth

Nathan said...

Rob,

I got it working, thanks in no small part to your posts. I was wondering if you know a way to create forms in the designer and use the forms as DockContent.

I can DockContent.Controls.Add all day long, but the designer would be nice.

Any tips?

Thanks,
nathan

chiamko said...

Hi:

I am doing some application development using DockPanel Suite in C#. I urgently need some examples to guide me along. I tried to download from the code samples you have put onto Google Codes but it seems like they have been removed. May I know is it possible for you to put it up again?

Thank you very much for your help.

Rob Smyth said...

Hi Chiamko,

From what I can see, for a quick check, the examples are still there on GoogleCode here: http://code.google.com/p/dockpanelsuitcsharpexamples/

Have another try and get back to me if you still have trouble.

BTW: Check out the Visual Studio 2008 shell, it is fee distribution and may provide an alternative. Check it out here http://msdn.microsoft.com/en-us/vsx2008/products/bb933751.aspx.

chiamko said...

Hi:

Thank you very much for your help. I have managed to locate the code samples. I think it will take me a while to really figure out how to use this tool efficiently.

Thank you once again.

Carmen Serrano said...

hello, I would guide me in the process of how to install the DockPanel suite and with that version of Visual Studio supports ... Download the DockPanel DockPanel Suite 231 and Suite 231 source bin .. thanks

Dhimant Patel said...

Hi,

Really appreciate your provided guideline here on DockPanel usage.



I have one request - can you explain how a menuStrip and statusStrip could also be used with DockPanel Suite controls? I am a beginner C# developer and probably taking on too much but this is what I did:
1> Created Windows Form App under VS2010.

2> Set Form's IsMDIContainer to true.

3> Added manustrip+statusStrip and got basic MDI style app.

4> Then added DockPanel and DockContent.

5> Running that shows everything as expected but after clicking on DockContent - I lost titlebar (tab strip with "pin" on it ) as menubar sits on top of it.



I may be missing something very basic but thought would like to ask this anyway.



BTW I tried using other projects ["vicfirereader-read-only", "noetictools-read-only"] but failed to compile on missing dll etc. errors.



Thanks!
DP