ToolStripButton

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
Exam Prep. Guides
70-505 Study Guide
70-526 Study Guide

1. Forms Controls

2. Integrating Data
3. Printing/Reporting
4. Enhancing Usability
5. Asynchronous Prog.
6. Forms Controls
7. Configure/Deploy

edit
Exam 70-526 Preparation Guide: Create and configure menus.


Contents


A ToolStripButton is a toolbar button that supports images and text.

Inheritance hierarchy

System.Object 
  System.MarshalByRefObject 
    System.ComponentModel.Component 
      System.Windows.Forms.ToolStripItem 
        System.Windows.Forms.ToolStripButton


Useful properties

Hot Tracking

When you populate a ToolStrip with ToolStripButtons, the ToolStrip will look something similar to this.

Image:526-28.jpg

The buttons on the ToolStrip are flat, but when you hover over them they are highlighted as per the following image. This feature is called hot tracking.

Image:526-29.jpg


Button Style

Text or Image

The DisplayStyle property (inherited from ToolStripItem) determines whether an image or text or both is displayed on the button. The property takes one of four values contained in the ToolStripItemDisplayStyle enumeration.

  • Image - Specifies that only an image is to be rendered for this ToolStripItem.
  • ImageAndText - Specifies that both an image and text are to be rendered for this ToolStripItem. (Default state)
  • None - Specifies that neither image nor text is to be rendered for this ToolStripItem.
  • Text - Specifies that only text is to be rendered for this ToolStripItem.

Although ImageAndText is the default setting, when you add a button (at least in C# Express) the IDE defaults the property to Image.

Text Display

The way that the text appears on the button can be manipulated via three properties, TextAlign, TextDirection and TextImageRelation.

  • TextAlign is inherited from ToolStripItem, it allows the text to be aligned within the button in one of nine positions from a combination of top, middle or bottom and left, center or right.
  • TextDirection is inherited from ToolStripItem, it allows the text to be rotated within the button. The property takes one of four values contained in the ToolStripTextDirection enumeration.
    • Horizontal - Specifies horizontal text orientation.
    • Inherit - Specifies that the text direction is inherited from the parent control. (Default state)
    • Vertical270 - Specifies that text is to be rotated 270 degrees clockwise.
    • Vertical90 - Specifies that text is to be rotated 90 degrees clockwise.
  • TextImageRelation is inherited from ToolStripItem, it allows the postion of the text and picture to be set with relation to one another. The property takes one of five values contained in the TextImageRelation enumeration.
    • ImageAboveText - Specifies that the image is displayed vertically above the text of a control.
    • ImageBeforeText - Specifies that the image is displayed horizontally before the text of a control. (Default state)
    • Overlay - Specifies that the image and text share the same space on a control.
    • TextAboveImage - Specifies that the text is displayed vertically above the image of a control.
    • TextBeforeImage - Specifies that the text is displayed horizontally before the image of a control.


Events

To simply add the click event, double-click on the button. For other events select the button and open the events pane.


MSDN resources


Previous_Page_.gif Next_Page_.gif
© 2007-2008 Mike Kitchen



Personal tools