Chapter 4 Working with Menus, Toolbars, and Dialog Boxes 109
- Click the Add ToolStripButton arrow on the right side of the new toolbar, and then click
the Button item.
Add ToolStripButton adds more items to your toolbar, such as buttons, labels, split
buttons, text boxes, combo boxes, and other useful UI elements. You’ve now created
a custom toolbar button; by default, it contains a picture of a mountain and a sun. - Widen the form window to ensure that you can see all the tool strip items.
- Right-click the new button, point to DisplayStyle, and click ImageAndText.
Your new button displays both text and a graphical image on the toolbar. Visual Studio
names your new button ToolStripButton1 in the program, and this name appears by
default on the toolbar. If necessary, widen the form window to see the new button,
because it contains the default text value ToolStripButton1.
- Select the ToolStripButton1 object.
- In the Properties window, change the ToolStripButton1 object’s Text property to Color,
which is the name of your button on the form, and then press ENTER.
The Color button appears on the toolbar. You’ll use this button later in the program
to change the color of text on the form. Now insert a custom bitmap for your button. - Right-click the Color button, and then click the Set Image command.
The Select Resource dialog box appears.
- Click Local Resource (if it is not already selected), and then click the Import button.
- Browse to the C:\Vb10sbs\Chap04 folder, click the ColorButton .bmp bitmap file that
I created for you, click Open, and then click OK.
Visual Studio loads the pink, blue, and yellow paint icon into the Color button, as
shown in the following screen shot: