With the ToolTip class, you can provide hints to a user when the user places the pointer on a control. The ToolTip class is typically used to alert users to the intended use of a control. For example, you can specify ToolTip text for a TextBox control that accepts a name, specifying the format of the name to be typed into the control. In addition to providing hints, you can also use the ToolTip class to provide run time status information. For example, you can use the ToolTip class to display connection speed and line quality data when the user moves the pointer onto a PictureBox control that displays Internet connection status.
The ToolTip class can be used in any container. To explicitly specify a container, use the ToolTip(IContainer) constructor. A single ToolTip component typically is used to create ToolTips for multiple controls on a single form. After you create a ToolTip, use a separate call to the SetToolTip method to associate ToolTip display text to an individual control. Then when the user moves the pointer on a control, the ToolTip with its text is displayed. You can call SetToolTip more than once for the same control to change the text that is associated with the control. To get the text that is associated with a control, use the GetToolTip method. To remove all ToolTip text associations with an instance of the ToolTip class, use the RemoveAll method.
Note: |
|---|
ToolTip text is not displayed for controls that are disabled. Unless the
ShowAlways property is set to true, ToolTips are not displayed when their container is inactive.
|
The ToolTip class provides the following properties and methods to modify the default behavior and appearance of a ToolTip.
Category
|
Associated members
|
|---|
Manual display
| Active, Show, Hide, ShowAlways, Popup, StopTimer |
ToolTip timing
| AutoPopDelay, InitialDelay, ReshowDelay, AutomaticDelay, StopTimer |
Content
| SetToolTip, GetToolTip, StripAmpersands, ToolTipIcon, ToolTipTitle, RemoveAll |
Appearance
| BackColor, ForeColor, IsBalloon, OwnerDraw, UseAnimation, UseFading |
If you want to disable all ToolTip text so that it cannot be displayed in your application, you can use the Active property. Usually the ToolTip is drawn by the operating system, but to customize the appearance of the ToolTip, you can set the OwnerDraw property to true and handle the Draw event.
The ToolTipTitle class implements the System.ComponentModel..::.IExtenderProvider interface, which has a single method, CanExtend. ToolTips extend controls on the same form at design time, adding a ToolTip property. For more information about extender providers, see Extender Providers.