Section 13.9. ToolTips


13.9. ToolTips

In Chapter 2, we discussed tool tipsthe helpful text that appears when the mouse hovers over a GUI control. The tool tips displayed in Visual Studio serve as useful reminders of each toolbar icon's functionality. Many programs use tool tips to remind users of each control's purpose. For example, Microsoft Word has tool tips that help users determine the purpose of the application's icons. This section demonstrates how to use the ToolTip component to add tool tips to your applications. Figure 13.31 describes common properties and a common event of class ToolTip.

Figure 13.31. ToolTip properties and an event.

ToolTip properties and an event

Description

Common Properties

AutoPopDelay

The amount of time (in milliseconds) that the tool tip appears while the mouse is over a control.

InitialDelay

The amount of time (in milliseconds) that a mouse must hover over a control before a tool tip appears.

ReshowDelay

The amount of time (in milliseconds) between which two different tool tips appear (when the mouse is moved from one control to another).

Common Event

Draw

Raised when the tool tip is displayed. This event allows programmers to modify the appearance of the tool tip.


When you add a ToolTip component from the Toolbox, it appears in the component traythe gray region below the Form in Design mode. Once a ToolTip is added to a Form, a new property appears in the Properties window for the Form's other controls. This property appears in the Properties window as ToolTip on, followed by the name of the ToolTip component. For instance, if our Form's ToolTip were named helpfulToolTip, you would set a control's ToolTip on helpfulToolTip property value to specify the control's tool tip text. Figure 13.32 demonstrates the ToolTip component. For this example, we create a GUI containing two Labels so that we can demonstrate a different tool tip for each Label. To make the sample outputs clearer, we set the BorderStyle property of each Label to FixedSingle, which displays a solid border. Since there is no event-handling code in this example, the class in Figure 13.32 is empty.

Figure 13.32. Demonstrating the ToolTip component.

 1  ' Fig. 13.32: FrmToolTipExample.vb 2  ' Demonstrating the ToolTip component. 3  Public Class FrmToolTipDemonstration 4     ' no event handlers needed for this example 5  End Class 

(a)

(b)

In this example, we named the ToolTip component labelsToolTip. Figure 13.33 shows the ToolTip in the component tray. We set the tool tip text for the first Label to "First Label" and the tool tip text for the second Label to "Second Label." Figure 13.34 demonstrates setting the tool tip text for the first Label.

Figure 13.33. ToolTip component in the component tray.


Figure 13.34. Setting a control's tool tip text.




Visual BasicR 2005 for Programmers. DeitelR Developer Series
Visual Basic 2005 for Programmers (2nd Edition)
ISBN: 013225140X
EAN: 2147483647
Year: 2004
Pages: 435

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net