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

Visual Studio IDE like Dock Container

By , 14 May 2009
 

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

Cristinel Mazarine
Romania Romania
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionIDE Like Tabbed Document.memberRitesh Khatri4 Nov '12 - 0:17 
QuestionLove itmemberstevecocks12 Sep '12 - 23:37 
QuestionImprove tagsmvpSergey Alexandrovich Kryukov22 Jun '12 - 15:58 
QuestionCrom.controls problem when moving windowsmemberolivier BALFOURIER14 Jun '12 - 21:02 
QuestionCan not download the source files..memberleilifan11 Apr '12 - 16:04 
Questionmodification to childforms.memberpasupulety31 Jan '12 - 20:18 
QuestionChanges to DockToolWindows .memberpasupulety31 Jan '12 - 20:12 
GeneralMy vote of 5memberVB_ Coder13 Jul '11 - 10:45 
GeneralDock container with Textbox issuesmemberChalcy12 May '11 - 1:17 
AnswerRightToLeft Not Work.memberBiyuk Sadeghi Lahijan28 Feb '11 - 4:27 
QuestionAdding Dockables at Design Editor?memberBarzille31 Dec '09 - 0:23 
GeneralVS2008 complains when I load the example projectmemberIvanBohannon26 Oct '09 - 3:55 
GeneralMy vote of 1membersmton13 Jul '09 - 12:51 
GeneralRe: My vote of 1memberjaimi21 Jul '09 - 4:17 
GeneralRe: My vote of 1memberJohnny J.31 May '10 - 2:27 
GeneralRe: My vote of 1memberRugbyLeague10 May '12 - 4:16 
GeneralBug - Text selection with mouse does not workmemberFredo5 Jun '09 - 0:59 
GeneralSome questionsmemberLomionAcc20 May '09 - 6:03 
GeneralRe: Some questionsmemberAjunta17 Aug '09 - 0:43 
GeneralSome important issues with dockingmemberdpk_kbsht13 May '09 - 21:04 
AnswerRe: Some important issues with dockingmembercromul14 May '09 - 8:26 
GeneralCompared with WeifenLuo's DockPanel SuitememberPinx12 May '09 - 3:47 
GeneralRe: Compared with WeifenLuo's DockPanel Suitemembervincezed9 Apr '11 - 3:21 
GeneralRe: Compared with WeifenLuo's DockPanel SuitememberPinx11 Apr '11 - 2:30 
GeneralThe DockContainer class is the user control which host the tool windows.memberIraticus9 May '09 - 6:38 

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 14 May 2009
Article Copyright 2008 by Cristinel Mazarine
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid