Using the Code

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.

privatevoid 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.

privatevoid 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:

Comments and Discussions

As stated in the subject, if you use DockableToolWindow as your base form class, it will not call the events assigned in AddToolWindow(). I dont understand how someone is supposed to add controls to these forms other than programmatically. Or am I doing something wrong?

The DockContainer control has defined these events:
AutoHidePanelToggled.....Event raised when auto-hide was toggled for a panel
ContextMenuRequest.......Event raised when context menu request was made.
MinimumSizeChanged.......This event occurs when the minimum allowed size for the container was changed. The form on which this container is placed should be sized to display the entire container

The rest of the events are those defined public in base classes (System.Windows.Forms.Control, etc).

Usually, if you have an issue on which you need help you should put it in a form like this:

>> What is happening (short and explicit statements)
>> What you expect to happen (short and explicit statements)