Export (0) Print
Expand All

ToolStripContainer Class

Note: This class is new in the .NET Framework version 2.0.

Provides panels on each side of the form and a central panel that can hold one or more controls.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
public class ToolStripContainer : ContainerControl
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
public class ToolStripContainer extends ContainerControl
ComVisibleAttribute(true) 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
public class ToolStripContainer extends ContainerControl

The ToolStripContainer consists of an expandable and collapsible ToolStripPanel on each side of the control, and a central ToolStripContentPanel. Use a ToolStripPanel to hold one or more ToolStrip, MenuStrip, or StatusStrip controls. Use the central ToolStripContentPanel to hold other controls.

You can hide each of the top, bottom, left, and right panels by setting their respective TopToolStripPanelVisible, BottomToolStripPanelVisible, LeftToolStripPanelVisible, and RightToolStripPanelVisible properties to false. By default, each of these properties is true at design time. Also at design time, the ToolStripContainer appears with its top panel already expanded.

The following code example demonstrates adding a ToolStripContainer and a ToolStrip to a Windows Forms, adding items to the ToolStrip, and adding the ToolStrip to the TopToolStripPanel of the ToolStripContainer.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


public class Form1 : Form
{
    private ToolStripContainer toolStripContainer1;
    private ToolStrip toolStrip1;

    public Form1()
    {
        InitializeComponent();
    }
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.Run(new Form1());
    }

    private void InitializeComponent()
    {
        toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
        toolStrip1 = new System.Windows.Forms.ToolStrip();
        // Add items to the ToolStrip.
        toolStrip1.Items.Add("One");
        toolStrip1.Items.Add("Two");
        toolStrip1.Items.Add("Three");
        // Add the ToolStrip to the top panel of the ToolStripContainer.
        toolStripContainer1.TopToolStripPanel.Controls.Add(toolStrip1);
        // Add the ToolStripContainer to the form.
        Controls.Add(toolStripContainer1);
 
    }
}

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
         System.Windows.Forms.ScrollableControl
           System.Windows.Forms.ContainerControl
            System.Windows.Forms.ToolStripContainer

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft