Create ToolWIndowContainer / WinForms

Docking/MDI for Windows Forms Forum

Posted 3 years ago by Reinhardt Software GmbH - Reinhardt Software GmbH
Version: 21.1.1

Hi Support Team.

I need to do the following:

- Find out, whether there is a ToolWindowContainer present, which is Docked on right side of screen and set to Auto Hide

- if so, I need to activate a new ToolWindow within this container

- otherwise, I need to create such Container (right side, auto hide) and then activate the new window.

My first issue is, that I do not know how to iterate through all ToolWindowContainers (couäd not find any property in DockManager), and that I could not find any samples on how to create and activate a new ToolWindowContainer.

Any help would be much appreciated.

Best regards


Comments (2)

Answer - Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Marc,

The AutoHideContainer instances (which hold a ToolWindow in auto-hide mode) are created on the control which is hosting DockManager. I put together a sample function to illustrate getting the AutoHideContainer for a particular side.

/// <summary>
/// Gets the AutoHideContainer, if any, on the given side of a DockManager.
/// </summary>
/// <param name="dockManager">The DockManager to examine.</param>
/// <param name="dockStyle">Indicates the left, top, right, or bottom side.</param>
/// <returns>An AutoHideContainer if found; otherwise false.</returns>
private AutoHideContainer GetAutoHideContainer(DockManager dockManager, DockStyle dockStyle) {
    // Make sure the DockManager is hosted
    if (dockManager.HostContainerControl != null) {
        // Iterate all the controls on the host control
        foreach (var control in dockManager.HostContainerControl.Controls) {
            // Is the control an AutoHideContainer?
            if (control is AutoHideContainer autoHideContainer) {
                // Is the AutoHideContainer on the desired side?
                if (autoHideContainer.Dock == dockStyle) {
                    return autoHideContainer;

    // Not found
    return null;

Then you could perform logic on your ToolWindow based on the presence of that AutoHideContainer.

// Create a new ToolWindow
ToolWindow toolWindow = CreateNewToolWindow();

// Look for an AutoHideContainer on the right side
var rightSideAutoHideContainer = GetAutoHideContainer(this.dockManager, DockStyle.Right);
if (rightSideAutoHideContainer != null) {
    // Attach to the right side AutoHideContainer
    toolWindow.DockTo(rightSideAutoHideContainer, DockOperationType.Attach);
else {
    // Dock to the right of DockManager
    toolWindow.DockTo(dockManager, DockOperationType.RightOuter);
    // Change the state to auto-hide
    toolWindow.State = ToolWindowState.AutoHide;

// Activate the new tool window

This should get you what you were looking for if I understood the request correctly. Please reach out if it does not.

Actipro Software Support

Posted 3 years ago by Reinhardt Software GmbH - Reinhardt Software GmbH

Dear Support Team,

thank you very much, works great. Excactly what I was looking for.

Best regards


The latest build of this product (v24.1.0) was released 4 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.