The ToolTip component allows you to provide tooltip help when the user hovers the mouse over a control. After you add a ToolTip component to a form, the other controls on the form get a special ToolTip property. For example, suppose that you create a ToolTip component named ttHint. Then a button on the form would have a new property named ToolTip on ttHint. Set that property to the text you want the ToolTip to display, and you are all set.
The following table describes the ToolTip component’s most useful properties.
Property | Purpose |
---|---|
Active | Determines whether the component displays tooltips. |
AutomaticDelay | Sets the AutoPopDelay, InitialDelay, and ReshowDelay properties to values that are appropriate for this value. |
AutoPopDelay | The number of milliseconds before the tooltip disappears if the mouse remains stationary in the tooltip’s area. |
BackColor | Determines the tooltip’s background color. |
ForeColor | Determines the tooltip’s foreground color. |
InitialDelay | The number of milliseconds that the mouse must remain stationary inside the tooltip’s area before the component displays the tooltip. |
IsBalloon | Determines whether the tooltip is displayed as a balloon rather than a rectangle. |
OwnerDraw | Determines whether your code will draw the tooltip. If you set this to True, catch the ToolTip component’s Draw method and draw the tooltip. Parameters to the method give the Graphics object to use, the bounds of the area to draw, and the tooltip text. This property is ignored if IsBalloon is True. |
ReshowDelay | The number of milliseconds before the next tooltip will display when the mouse moves from one tool tip area to another. The idea is that subsequent tooltips display more quickly if one is already visible. |
ShowAlways | Determines whether the component still displays tooltips, even if the form does not have the focus. The mouse still must hover over the tooltip area as usual if ShowAlways is True. |
StripAmpersands | Determines whether the component removes ampersand characters from tooltip text. This can be useful if the tooltip text looks like menu and label captions where ampersands are converted into underscores. |
UseAnimation | Determines whether animation effects are used to show and hide the tooltip. |
UseFading | Determines whether fading effects are used to show and hide the tooltip. |
The ToolTip component’s SetToolTip method lets a program associate a tooltip with a code at runtime. The following code adds tooltip text to several address controls:
ttHint.SetToolTip(txtFirstName, "Customer first name") ttHint.SetToolTip(txtLastName, "Customer last name") ttHint.SetToolTip(txtStreet, "Mailing address street number and name") ttHint.SetToolTip(txtCity, "Mailing address city") ttHint.SetToolTip(cboState, "Mailing address state") ttHint.SetToolTip(txtZip, "Mailing address ZIP code")
The following table lists the ToolTip component’s most useful methods.
Method | Purpose |
---|---|
GetToolTip | Returns a control’s associated tooltip text. |
RemoveAll | Removes all tooltip text associated with this ToolTip component. |
SetToolTip | Sets a control’s associated tooltip text. Set the text to Nothing or an empty string to remove that control’s tooltip text. |
Show | Displays a tooltip over a specific control. Different overloaded versions let you specify the tooltip’s location and duration. |