Click here to Skip to main content
15,860,972 members
Articles / Programming Languages / C#

Visual Studio IDE like Dock Container

Rate me:
Please Sign up or sign in to vote.
4.38/5 (41 votes)
14 May 2009Public Domain2 min read 371.9K   21.4K   256   91
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 Image 2AddToolWindow method. This method adds a tool window to be managed by dock container. The caller must show the form to make it visible.

C#
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 Image 3DockToolWindow method.

C#
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 Image 4UndockToolWindow 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:

C#
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 Image 5MinimumSizeChanged event to enforce the minimum dimensions of the container form.

C#
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


Written By
Romania Romania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionInstructions Pin
lord_raven_lee11-Mar-23 18:29
lord_raven_lee11-Mar-23 18:29 
QuestionVB.NET 2019 Pin
Milan Hudec19-Sep-20 23:34
Milan Hudec19-Sep-20 23:34 
SuggestionAlternative Pin
varandas24-Apr-20 2:01
varandas24-Apr-20 2:01 
QuestionDifficult to use source code in client application as full source code is not available on given links Pin
Member 1181930217-Jul-19 21:15
Member 1181930217-Jul-19 21:15 
AnswerRe: Difficult to use source code in client application as full source code is not available on given links Pin
OriginalGriff17-Jul-19 21:18
mveOriginalGriff17-Jul-19 21:18 
GeneralExternal link cannot be accessed Pin
KudoShin27-May-15 0:15
KudoShin27-May-15 0:15 
QuestionAny way to not resize the main/filled dock when docking a side panel Pin
JudyCW26-Jun-13 18:56
JudyCW26-Jun-13 18:56 
QuestionIDE Like Tabbed Document. Pin
Ritesh Khatri4-Nov-12 0:17
Ritesh Khatri4-Nov-12 0:17 
I need Tabbed Control insted of Dock container...


Have any one have like this code please help me..
if any one have.
Thanks & Regards

Ritesh Khatri (BCA)
Mo.8000533815
Email-rikiritesh@gmail.com

QuestionLove it Pin
stevecocks12-Sep-12 23:37
stevecocks12-Sep-12 23:37 
QuestionImprove tags Pin
Sergey Alexandrovich Kryukov22-Jun-12 15:58
mvaSergey Alexandrovich Kryukov22-Jun-12 15:58 
QuestionCrom.controls problem when moving windows Pin
olivier BALFOURIER14-Jun-12 21:02
olivier BALFOURIER14-Jun-12 21:02 
QuestionCan not download the source files.. Pin
leilifan11-Apr-12 16:04
leilifan11-Apr-12 16:04 
Questionmodification to childforms. Pin
pasupulety31-Jan-12 20:18
pasupulety31-Jan-12 20:18 
QuestionChanges to DockToolWindows . Pin
pasupulety31-Jan-12 20:12
pasupulety31-Jan-12 20:12 
GeneralMy vote of 5 Pin
VB_ Coder13-Jul-11 10:45
VB_ Coder13-Jul-11 10:45 
GeneralDock container with Textbox issues Pin
Chalcy12-May-11 1:17
Chalcy12-May-11 1:17 
AnswerRightToLeft Not Work. Pin
Biyuk Sadeghi Lahijan28-Feb-11 4:27
Biyuk Sadeghi Lahijan28-Feb-11 4:27 
QuestionAdding Dockables at Design Editor? Pin
Barzille31-Dec-09 0:23
Barzille31-Dec-09 0:23 
GeneralVS2008 complains when I load the example project Pin
IvanBohannon26-Oct-09 3:55
IvanBohannon26-Oct-09 3:55 
GeneralMy vote of 1 Pin
smton13-Jul-09 12:51
smton13-Jul-09 12:51 
GeneralRe: My vote of 1 Pin
jaimi21-Jul-09 4:17
jaimi21-Jul-09 4:17 
GeneralRe: My vote of 1 Pin
Johnny J.31-May-10 2:27
professionalJohnny J.31-May-10 2:27 
GeneralRe: My vote of 1 Pin
RugbyLeague10-May-12 4:16
RugbyLeague10-May-12 4:16 
GeneralBug - Text selection with mouse does not work Pin
Fred dBu5-Jun-09 0:59
Fred dBu5-Jun-09 0:59 
GeneralSome questions Pin
LomionAcc20-May-09 6:03
LomionAcc20-May-09 6:03 

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

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