Export (0) Print
Expand All

ToolBar.Appearance Property

Gets or set the value that determines the appearance of a toolbar control and its buttons.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public ToolBarAppearance Appearance { get; set; }

Property Value

Type: System.Windows.Forms.ToolBarAppearance
One of the ToolBarAppearance values. The default is ToolBarAppearance.Normal.

ExceptionCondition
InvalidEnumArgumentException

The assigned value is not one of the ToolBarAppearance values.

The Appearance property affects the appearance of the buttons assigned to the toolbar. When the appearance is set to ToolBarAppearance.Normal, the toolbar's buttons appear three-dimensional and raised. Set the Appearance property of the toolbar to ToolBarAppearance.Flat to give the toolbar's buttons a flat appearance. As the mouse pointer moves over the flat buttons, they appear raised and three-dimensional. Separators on a ToolBar with the Appearance property set to Flat appear as etched lines rather than spaces between the raised buttons. The flat style buttons give your application a more Web-like look.

The following code example creates a ToolBar control, sets some of its common properties, and adds it to a Form. Delegates are also added to the ButtonClick and ButtonDropDown events. This example requires that a ToolBar named toolBar1 and an ImageList named imageList1 have been declared.

private void AddToolBar()
{
   // Add a toolbar and set some of its properties.
   toolBar1 = new ToolBar();
   toolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
   toolBar1.BorderStyle = System.Windows.Forms.BorderStyle.None;
   toolBar1.Buttons.Add(this.toolBarButton1);
   toolBar1.ButtonSize = new System.Drawing.Size(24, 24);
   toolBar1.Divider = true;
   toolBar1.DropDownArrows = true;
   toolBar1.ImageList = this.imageList1;
   toolBar1.ShowToolTips = true;
   toolBar1.Size = new System.Drawing.Size(292, 25);
   toolBar1.TabIndex = 0;
   toolBar1.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
   toolBar1.Wrappable = false;

   // Add handlers for the ButtonClick and ButtonDropDown events.
   toolBar1.ButtonDropDown += 
     new ToolBarButtonClickEventHandler(toolBar1_ButtonDropDown);
   toolBar1.ButtonClick += 
     new ToolBarButtonClickEventHandler(toolBar1_ButtonClicked);

   // Add the toolbar to the form. 
   this.Controls.Add(toolBar1);
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft