From SC Crom-Osec SRL (En)

Contents

Image:cfl.png Dock container

This product is available under Crom Free License.


Introduction

The dock container is a user control which allows guided dock of child forms on a parent form.

This article describes how to use the free dock container library in your applications.

You can download full sources from here

Full documentation for the product can be accessed here.


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

Image:DockContainerSample.png


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 specialize this class. By default this property allows docking the tool window on all panels. Overriding this property can be changed the dock behavior of the tool window (for example can allow only dock left or right).

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

This control should be added to the main form and docked fill. Then can add forms to it using 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 ();
}         

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

Full documentation of this product can be accessed at the site mentioned on 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.