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.

Exception Condition
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
Available since 1.1
Return to top
Show: