Creating a toolbar
Outlines the steps of creating toolbars in a windows application
Toolbars essentially provide the same functionalities as menus. The most commonly used menu options are also displayed using a toolbar so that the user can access them quickly.
The Visual C# IDE provides the ToolStrip control to create a toolbar easily. Let us see how to use this control:
1. Open the previous project if not opened already. Drag the ToolStrip control from the Menus & Toolbars section of the Toolbox and drop it just below the MenuStrip control (the menu that we have created earlier).
2. When the ToolStrip control is added to the form, a drop down list appears on it. Expanding this list will display the elements that we can add to the toolbar. Select the Button element as we want to add a button to our toolbar:
3. Now that we have a button on our toolbar, we will set its properties. Select the button by clicking on it and open the properties window.
The first property we will set is the Image property. This property is used to display an image on the button. To set the Image property, click on the button in the cell next to it (in the properties window). We will get a dialog box similar to the one we have seen while attaching images with menu options:
Select the Local resource radio button and then click on the Import button. This will allow us to browse the folder where the image files are stored and select the appropriate image file. Once we select the image file, it will be displayed in the large gray box of this dialog box. Click OK to continue.
4. The next property we will set is the ToolTipText property. This property displays a text when the user places the mouse cursor on a toolbar button. This helps the user to identify the function of the button.
To set this property, just type the text to be displayed in the empty cell next to the ToolTipText property in the properties window. For example, for the new file button, we can type `New' as its ToolTipText property. When the user hovers the mouse on this button, the text `New' will be displayed as a tool tip.
One more property that we can set is the Name property. We use this property to access the toolbar buttons in our code. However, for our sample application, we will use the default names provided by the Visual C# IDE.
Note that it is not necessary to create toolbar buttons for all the menu options. The convention is to create toolbar buttons for the most frequently used options.
To group the toolbar buttons, we use the Separator element from the drop down list used to add elements to the toolbar.
We have now designed the menu system and toolbar for our application. In the next section, we will learn how to add functionalities to them.



