Changes

Building a Visual Basic Toolbar

5 bytes added, 14:57, 9 April 2009
no edit summary
== Creating a Toolbar ==
Toolbars are referred to in Visual Basic as ''ToolStrips''. The first step in creating a toolbar is to add a ''ToolStrip'' control to the form. Begin by starting Visual Studio and creating a new Windows Application project named ''vbToolbar'' (for details on creating new project see [[Creating a New Visual Basic Project]]). When the new project has been created and the default form appears , display the ''Toolbox'' and double click on the ''ToolStrip'' control to add it to the form:
[[Image:visual_basic_new_toolbar.jpg| Adding a new Toolbar in Visual Studio]]
Tooltips are small messages that are displayed when the mouse pointer moves over a control. They are intended to provide a brief description of the function of the control. Tooltips are especially useful for toolbar controls because such controls are typically small buttons that display only a small icon. This means it is often not clear exactly what a control does. By defining a Tooltip, it is possible to provide useful tips to the user as to what the control does.
Tooltips are specified via the ''Text'' property of the control in question. To add a Tooltip to the first button in our example toolbar, select the button in the form and change the ''Text'' property in the ''Properties'' panel to ''Displays Date and Time''. Similarly change the ''Text'' property of the second control to ''Hides Date and Time''.
Press '''F5''' to build and run the application. When the application starts, move the mouse over each button. AS As the mouse hovers over each control the tooltip text should appear.
== Programming Toolbar Controls ==
== Changing the Toolbar Position ==
By default, the Visual Basic ToolStrip object will be position positioned across the top edge of the form. Whilst this is the most common location for a toolbar, it can be positioned along the top, bottom, left or right edges of a form, or even in the center of the form using the ''Dock'' property. To modify this property, select the ''ToolStrip'' object in the form and look for the ''Dock'' property in the Properties panel. Click on the down arrow in the value field to display the location map:
[[Image:visual_basic_toolbar_location.jpg| Changing location of Visual Basic Toolbar]]
Click on the new location and the toolbar will move to the new position.