April 26, 2013

Visual Studio-style docking windows with DockPanel Suite

Installation

These instructions work with Visual Studio 2010.

Download the binaries from the DockPanel Suite website. In Visual Studio, select Choose Items from the Toolbox window's context menu (it may be hidden, display it with View > Toolbox). In .NET Framework Components click Browse and select the WeifenLuo.WinFormsUI.Docking.dll assembly downloaded from the website. This will add the DockPanel component to the Toolbox.

Usage

The container form must be an MDI form containing a DockPanel component. Add a new form to your Visual Studio project, and set its IsMdiContainer property to True. Place a DockPanel component on it and make it fill up the form's client area by setting its Dock property to Fill.

To add docking windows to the container form you can instantiate them in code and associate them to the container form by calling the Show method specifying the DockPanel as the owner.

public partial class Form1 : Form
{
  Form2 formA = new Form2();
  Form2 formB = new Form2();
  Form2 formC = new Form2();
 
  public Form1()
  {
    InitializeComponent();

    formA.Show(this.dockPanel1);
    formB.Show(this.dockPanel1);
    formC.Show(this.dockPanel1);
  }
}

Here's the result.





No comments:

Post a Comment