Click here to Skip to main content
Click here to Skip to main content

Visual Studio IDE like Dock Container

, 14 May 2009
Rate this:
Please Sign up or sign in to vote.
Free Windows dock container

Important Note

We intend to create a new release of this open source product at the end of the next month (June 28, 2009). Please send any bug you've found (or desired change request) at contact@osec.ro .

Thank you all for using this product.

Introduction

This article describes how to use the free dock container library in your applications.
You can download the full source from here. The full documentation for the product can be accessed here.

Here is a image of the sample project of this application:

Crom

Background

This user control is made in C# and allows docking child forms on Left, Right, Top, Bottom and Fill.
The dock is guided by dock guiders.

Using the Code

There are two important classes in this library: DockableToolWindow and DockContainer.

The DockableToolWindow is the base class for the tool windows.

The most important property from this class is AllowedDock. This property returns the allowed dock values for the tool window which specializes this class. By default, this property allows docking the tool window on all panels. Overriding this property can change the dock behavior of the tool window (for example can allow only dock left or right).

The DockContainer class is the user control which hosts the tool windows.

This control should be added to the main form and docked fill.
Then you can add forms to it using the AddToolWindow method. This method adds a tool window to be managed by dock container. The caller must show the form to make it visible.

private void ShowNewForm ()
{
   // Create a new instance of the child form.
   DockableToolWindow childForm = new DockableToolWindow ();

   // Add the form to the dock container
   _dockContainer1.AddToolWindow (childForm);

   // Show the form
   childForm.Show ();
}

The forms can be added and docked with a single call to the DockToolWindow method.

private void OnCreateNewToolWindowDockedLeft (object sender, EventArgs e)
{
   // Create a new instance of the child form.
   DockableToolWindow childForm = new DockableToolWindow ();

   // Add and dock the form in the left panel of the container
   _dockContainer1.DockToolWindow (childForm, zDockMode.Left);

   // Show the form
   childForm.Show ();
} 

The tool windows can be undocked using the UndockToolWindow method. Here is a sample of how to un-dock the top level tool-window from the left panel and then move it to an arbitrary location:

   DockableToolWindow toolWindow = _dockContainer.GetTopToolWindow(zDockMode.Left);
   if (toolWindow != null)
   {
      _dockContainer.UndockToolWindow(toolWindow);
      toolWindow.Location = new Point(300, 100);
   } 

It is important for the users of this library to use the MinimumSizeChanged event to enforce the minimum dimensions of the container form.

private void OnDockContainerMinSizeChanged (object sender, EventArgs e)
{
   int deltaX = Width  - _dockContainer1.Width;
   int deltaY = Height - _dockContainer1.Height;

   MinimumSize = new Size (
      _dockContainer1.MinimumSize.Width  + deltaX,
      _dockContainer1.MinimumSize.Height + deltaY);
}

Points of Interest

The full documentation of this product can be accessed at the site mentioned at the beginning of this article. Please contact us at contact@osec.ro for additional information.

History

  • First version of this product was released on 2008.05.07

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication

Share

About the Author

No Biography provided

Comments and Discussions

 
GeneralRe: Some questions PinmemberAjunta17-Aug-09 0:43 
GeneralSome important issues with docking Pinmemberdpk_kbsht13-May-09 21:04 
AnswerRe: Some important issues with docking Pinmembercromul14-May-09 8:26 
GeneralCompared with WeifenLuo's DockPanel Suite PinmemberPinx12-May-09 3:47 
GeneralRe: Compared with WeifenLuo's DockPanel Suite Pinmembervincezed9-Apr-11 3:21 
GeneralRe: Compared with WeifenLuo's DockPanel Suite PinmemberPinx11-Apr-11 2:30 
GeneralThe DockContainer class is the user control which host the tool windows. PinmemberIraticus9-May-09 6:38 
NewsRe: The DockContainer class is the user control which host the tool windows. Pinmembercromul10-May-09 7:32 
GeneralEvents not triggering when you derive from DockableToolWindow PinmemberJayKnobler22-Apr-09 19:00 
AnswerRe: Events not triggering when you derive from DockableToolWindow Pinmembercromul24-Apr-09 2:18 
QuestionI need a Help in your control Pinmembertusharcapoor4-Feb-09 21:16 
GeneralDock My Form Pinmembercanci18-Dec-08 7:45 
AnswerRe: Dock My Form Pinmembercromul19-Dec-08 5:20 
AnswerRe: Dock My Form PinmemberAntonioElVampiro13-Jan-09 12:36 
I think what you want is to add you form as a DockToolWindow.
To do this, just go to you code (Form1.cs) and make it inherit from DockableToolWindow instead of Form.
 
Here is an example:
 

public partial class Form1 : Form
{
......
}

 
Replace it with:
 

public partial class Form1 : DockableToolWindow
{
......
}

 
Don't forget to add the reference:
using Crom.Controls;
 
To attach the form to the dock container you can do this:
 

DockableToolWindow vs = new Form1();
dockContainer1.DockToolWindow(vs);
vs.Show();

 
If you have problems loading your form with the visual studio form designer, just give visual studio a break, close the solution and open it again. I'm sure it works.
GeneralRe: Dock My Form [modified] Pinmemberjoeller9-Apr-09 6:28 
GeneralRe: Dock My Form Pinmemberjoeller9-Apr-09 10:26 
GeneralVista Bug not showing hide buttons Pinmembergrahamdodd27-Nov-08 14:18 
GeneralRe: Vista Bug not showing hide buttons Pinmembercromul1-Dec-08 1:26 
GeneralRe: Vista Bug not showing hide buttons Pinmembernymrin28-Jan-09 12:12 
GeneralRe: Vista Bug not showing hide buttons Pinmembernymrin28-Jan-09 12:40 
QuestionActive Window Pinmemberambarishtv28-Aug-08 18:46 
AnswerRe: Active Window Pinmembercromul4-Nov-08 10:27 
GeneralRedocking forms Pinmemberaiman6925-Aug-08 23:10 
GeneralRe: Redocking forms Pinmembergjconely23-Oct-08 6:38 
GeneralRe: Redocking forms Pinmembercromul4-Nov-08 10:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140821.2 | Last Updated 14 May 2009
Article Copyright 2008 by Cristinel Mazarine
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid