.Net Controls: ToolBar |
|
Overview |
Introduction |
A toolbar is a Windows control that allows the user the perform some actions on a form by clicking a button instead of using a menu. What a toolbar provides is a convenient group of buttons that simplifies the user's job by bringing the most accessible actions as buttons so that, instead of performing various steps to access a menu, a button on a toolbar can bring such common actions closer to the user. Toolbars usually display under the main menu. They can be equipped with buttons but sometimes their buttons or some of their buttons have a caption. Toolbars can also be equipped with other types of controls. To create a toolbar, on the Toolbox, click the Toolbox button and the form. By default, a toolbar is positioned on the top section of the form. Like a form, a toolbar is only a container and does not provide much role by itself. To make a toolbar efficient, you should equip it with the necessary controls. To add controls to a toolbar, on the Properties window, click the ellipsis button of the Buttons field. This would open the ToolBarButton Collection Editor. To add a control to a toolbar, in the ToolBarButton Collection Editor, click the Add button. The most common control used on a toolbar is a button. The types of buttons used are set using the Style property. A regular button has the PushButton style. The new button would appear empty. A button on a toolbar is a rectangular object with a picture on top.
The picture on the button should suggest what the button is used for but this is not always possible. Providing a picture is more important. The easiest way to provide pictures for your toolbar is by creating an image list and associating it with the toolbar. If a toolbar is given an image list, whenever you
add a button, use the ImageIndex property to specify the image that
would display on the button. You can keep adding buttons in this fashion. As a toolbar can be equipped with various types of controls, there are various types of buttons you can place on a toolbar. The types of buttons can be configured using the Style property on the Object Inspector. |
|
Toolbar Programming |
The controls on a toolbar are controls by their owner, the toolbar. In order to write code for a control, you must first locate it. The buttons are located in a collection called Buttons. Each button can be located by calling the IndexOf() methods. Once this gives you access to a button, you can write its code as you see fit. |
|
|
||
Home | Copyright © 2004-2010 FunctionX, Inc. | |
|