ToolTip
sIn Chapter 2, we demonstrated tool tips—the helpful text that appears when the mouse hovers over an item in a GUI. Recall that the tool tips in Visual Studio (and most apps with GUIs) help you become familiar with the IDE’s features and serve as useful reminders for each toolbar icon’s functionality. This section demonstrates how to use the ToolTip
component to add tool tips to your apps. Figure 14.31 describes common properties and a common event of class ToolTip
.
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 about to be 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 tray—at the bottom of the window when the Form
is 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 helpful-ToolTip
, you would set a control’s ToolTip on helpfulToolTip property value to specify the control’s tool tip text. Figure 14.32 demonstrates the ToolTip
component. For this example, we create a GUI containing two Label
s, so we can demonstrate different tool tip text for each Label
. Since there’s no event-handling code in this example, we do not show you the code for the Form
class.
In this example, the IDE named the ToolTip
component toolTip1
. Figure 14.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 14.34 demonstrates setting the tool tip text for the first Label
.