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

Visual Studio IDE like Dock Container

By , 14 May 2009
Rate this:
Please Sign up or sign in to vote.

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

About the Author

No Biography provided

Comments and Discussions

 
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 
GeneralRe: Redocking forms Pinmembercromul4-Nov-08 10:28 
QuestionLinks not working Pinmembermorphias0@yahoo.com18-Aug-08 4:53 
GeneralRe: Links not working Pinmembercromul4-Nov-08 10:29 
GeneralOther MDI forms PinmemberGreg Conely7-Jul-08 6:17 
AnswerRe: Other MDI forms Pinmembercromul7-Jul-08 8:41 
GeneralRe: Other MDI forms Pinmemberaiman6925-Aug-08 22:48 
if I understand ur question!!!Confused | :confused:
 
if u want to dock forms that u create in design time,
u have to change the "Inherits" statment
from "Inherits System.Windows.Forms.Form" ---> "Inherits DockableToolWindow"
 
u may do this by editing the file Form1.Designer.vb (if ur form is called form1) by any text editor
 
then in the code u should dock the form with the container:
 
DockContainer1.DockToolWindow(Form1, zDockMode.Top)
Form1.Show()
 
Aiman Ibrahim
Question"not always on top" PinmemberAVXT4-Jul-08 6:46 
AnswerRe: "not always on top" Pinmembercromul7-Jul-08 8:43 
GeneralDocumentation PinmemberAngelo DeFusco30-Jun-08 17:48 
AnswerRe: Documentation Pinmembercromul1-Jul-08 21:58 
QuestionBug 1 and about 2 kind improvement programs Pinmemberseeper16-Jun-08 23:44 
AnswerRe: Bug 1 and about 2 kind improvement programs Pinmembercromul1-Jul-08 22:01 
QuestionTabButton TextRenderer problem Pinmemberel Golem7-Jun-08 8:35 
AnswerRe: TabButton TextRenderer problem Pinmembercromul9-Jun-08 8:03 
GeneralRe: TabButton TextRenderer problem PinmemberTimMcQueen29-Dec-08 7:37 
AnswerRe: TabButton TextRenderer problem Pinmembercromul15-Jan-09 12:55 
GeneralRe: TabButton TextRenderer problem Pinmemberstrangeloop4-Jan-09 3:36 
AnswerRe: TabButton TextRenderer problem PinmemberKompiler17-Sep-09 1:29 
GeneralDockStyle.Fill doesn´t work PinmemberMichaelgor31-May-08 6:11 
GeneralRe: DockStyle.Fill doesn´t work Pinmembercromul2-Jun-08 7:35 
GeneralRe: DockStyle.Fill doesn´t work PinmemberMichaelgor2-Jun-08 8:06 
AnswerRe: DockStyle.Fill doesn´t work Pinmembercromul2-Jun-08 10:49 
Generalpls provide demo PinmemberNitin Sawant29-May-08 18:43 
GeneralRe: pls provide demo Pinmembercromul30-May-08 7:45 
QuestionAdd controls to the DockToolWindow? Pinmembergjconely29-May-08 8:12 
AnswerRe: Add controls to the DockToolWindow? Pinmembercromul29-May-08 9:24 
AnswerRe: Add controls to the DockToolWindow? Pinmemberaiman6925-Aug-08 23:06 
GeneralNot working in Vista Pinmembermuttok19-May-08 22:22 
GeneralRe: Not working in Vista Pinmembercromul20-May-08 10:31 
GeneralRe: Not working in Vista PinmemberMember 143090822-May-08 21:03 
AnswerRe: Not working in Vista Pinmembercromul23-May-08 6:26 
QuestionBug?? Pinmemberstuempfig19-May-08 11:53 
AnswerRe: Bug?? Pinmembercromul20-May-08 10:21 
GeneralPLEASE add a demo!!!!!! [modified] PinmemberBrad Bruce12-May-08 3:58 
AnswerRe: PLEASE add a demo - demo exists in sources package Pinmembercromul12-May-08 10:25 
GeneralRe: PLEASE add a demo - demo exists in sources package PinmemberBrad Bruce12-May-08 14:46 
AnswerRe: Pinmembercromul13-May-08 7:30 
GeneralRe: PinmemberBrad Bruce13-May-08 12:28 
AnswerRe: Pinmembercromul13-May-08 20:13 
GeneralRe: PinmemberBrad Bruce14-May-08 11:59 

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.140415.2 | Last Updated 14 May 2009
Article Copyright 2008 by Cristinel Mazarine
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid