Changes

Jump to: navigation, search

Building a Visual Basic Toolbar

2,310 bytes added, 20:42, 26 July 2007
no edit summary
[[Image:Exampl.jpg]]
 
== Adding Tooltip Text to Toolbar Controls ==
 
Tooltips are small messages which 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 which only display 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 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 the mouse hovers over each control the tooltip text should appear.
 
== Programming 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:Exampl.jpg]]
 
With the ''DateTimePicker'' control selected, change the ''Name'' property in the Properties panel to ''MyDateTime''.
 
Finally, we need to write the Visual Basic code to hide and show the date and time control. Double click on the first button in the toolbar to display the ''Click'' event procedure for this control. The event procedure needs to call the ''Show()'' method of the ''MyDateTime'' object as follows:
 
<pre>
 
</pre>
 
Similarly, we need to call the ''Hide()'' method of the ''MyDateTime'' object when the second button is pressed as follows:
 
<pre>
 
</pre>
 
Once the Visual Basic code has been written, press '''F5''' to build and run the application. When the toolbar buttons are clicked the date and time control will appear and disappear.
 
== Changing the Toolbar Position ==

Navigation menu