JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page


Windows users are familiar with toolbars-they're those bars full of buttons that appear under menu bars, as you see in Figure 10.4. There are various kinds of options here for the buttons in a toolbar-you can have standard push buttons, toggle buttons (that can appear up or pressed), drop-down buttons that can display a drop-down menu, and buttons that display images. Buttons also can be converted into separators, which display empty horizontal space to separate other buttons.

Click To expand
Figure 10.4: A toolbar at work.

Typically, the buttons in a toolbar correspond to the most popular menu items in the application. In such cases, the code for a toolbar button is easy to implement-you just use the corresponding MenuItem object's PerformClick method, which clicks the menu item just as if the user did.

Although toolbars are usually docked along the top of its parent window, they can actually be docked to any side of a window. Toolbars also can display tool tips when the user points the mouse pointer at a toolbar button. (Note that to display ToolTips, the ShowToolTips property must be set to True.)

When the Appearance property is set to Normal, the toolbar buttons appear raised (that is, three-dimensional). You can set the Appearance property of the toolbar to Flat to give the toolbar and its buttons a flat appearance. (Note that when the mouse pointer moves over a flat button, the button's appearance changes to three-dimensional.) The TextAlign property specifies the alignment of the text in a button, such as at the top of bottom of the button.

The Toolbar control allows you to create toolbars by adding ToolBarButton objects to the toolbar's Buttons collection. At design time, an editor appears to add buttons to a toolbar; each button can have text and/or an image (images come from an image list control). At run time, you can add or remove buttons from the toolbar using the Add and Remove methods of the Buttons property. And here's an interesting fact: The buttons in a toolbar do not get their own Click events-instead, you add code to the ButtonClick events of the toolbar. (You can tell what button was clicked by checking the Button property of the ToolBarButtonClickEventArgs argument passed to you.)

To create a collection of ToolBarButton controls to display in a toolbar, you add the buttons individually at design time, or at run time using the Add method of the Buttons property, or using the AddRange method to add a number of buttons at once.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor