Changes

Jump to: navigation, search

Building a Visual Basic Toolbar

92 bytes added, 20:56, 26 July 2007
no edit summary
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]]
Various types of control can be added to a toolbar. To add a control, simply click on the down arrow of the button on the toolbar. A menu will appear listing the various types of control which may be added. Select a button control. Once the new button control has been added, right click on the button to display a menu containing various options for modifying the control (including setting a new image on the button).
Using the above technique add two more buttons to the toolbar. Press '''F5''' to build and run the application. The application should appear as follows:
[[Image:visual_basic_toolbar_running.jpg| Visual Basic Toolbar Example]]
== Adding Tooltip Text to Toolbar Controls ==
In order to make the toolbar controls useful we need to write some Visual Basic code in the event procedures. For the purposes of this example, we will program two of our toolbar controls to hide and show a ''DateTimePicker'' control. Open the Toolbox if it is not already visible and double click on the ''DateTimePicker'' control to add it to the form. Move the new control so that it appears as follows:
[[Image:Examplvisual_basic_toolbar_datetime.jpg]]
With the ''DateTimePicker'' control selected, change the ''Name'' property in the Properties panel to ''MyDateTime''.

Navigation menu