1 out of 2 rated this helpful - Rate this topic

ToolTip Class

Represents a small rectangular pop-up window that displays a brief description of a control's purpose when the user rests the pointer on the control.

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Windows.Forms.ToolTip

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
public class ToolTip : Component, IExtenderProvider

The ToolTip type exposes the following members.

  Name Description
Public method ToolTip() Initializes a new instance of the ToolTip without a specified container.
Public method ToolTip(IContainer) Initializes a new instance of the ToolTip class with a specified container.
Top
  Name Description
Public property Active Gets or sets a value indicating whether the ToolTip is currently active.
Public property AutomaticDelay Gets or sets the automatic delay for the ToolTip.
Public property AutoPopDelay Gets or sets the period of time the ToolTip remains visible if the pointer is stationary on a control with specified ToolTip text.
Public property BackColor Gets or sets the background color for the ToolTip.
Protected property CanRaiseEvents Gets a value indicating whether the component can raise an event. (Inherited from Component.)
Public property Container Gets the IContainer that contains the Component. (Inherited from Component.)
Protected property CreateParams Infrastructure. Gets the creation parameters for the ToolTip window.
Protected property DesignMode Gets a value that indicates whether the Component is currently in design mode. (Inherited from Component.)
Protected property Events Gets the list of event handlers that are attached to this Component. (Inherited from Component.)
Public property ForeColor Gets or sets the foreground color for the ToolTip.
Public property InitialDelay Gets or sets the time that passes before the ToolTip appears.
Public property IsBalloon Gets or sets a value indicating whether the ToolTip should use a balloon window.
Public property OwnerDraw Gets or sets a value indicating whether the ToolTip is drawn by the operating system or by code that you provide.
Public property ReshowDelay Gets or sets the length of time that must transpire before subsequent ToolTip windows appear as the pointer moves from one control to another.
Public property ShowAlways Gets or sets a value indicating whether a ToolTip window is displayed, even when its parent control is not active.
Public property Site Gets or sets the ISite of the Component. (Inherited from Component.)
Public property StripAmpersands Gets or sets a value that determines how ampersand (&) characters are treated.
Public property Tag Gets or sets the object that contains programmer-supplied data associated with the ToolTip.
Public property ToolTipIcon Gets or sets a value that defines the type of icon to be displayed alongside the ToolTip text.
Public property ToolTipTitle Gets or sets a title for the ToolTip window.
Public property UseAnimation Gets or sets a value determining whether an animation effect should be used when displaying the ToolTip.
Public property UseFading Gets or sets a value determining whether a fade effect should be used when displaying the ToolTip.
Top
  Name Description
Public method CanExtend Returns true if the ToolTip can offer an extender property to the specified target component.
Public method CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public method Dispose() Releases all resources used by the Component. (Inherited from Component.)
Protected method Dispose(Boolean) Disposes of the ToolTip component. (Overrides Component.Dispose(Boolean).)
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Releases the unmanaged resources and performs other cleanup operations before the Cursor is reclaimed by the garbage collector. (Overrides Component.Finalize().)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected method GetService Returns an object that represents a service provided by the Component or by its Container. (Inherited from Component.)
Public method GetToolTip Retrieves the ToolTip text associated with the specified control.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method Hide Hides the specified ToolTip window.
Public method InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected method MemberwiseClone() Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method MemberwiseClone(Boolean) Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public method RemoveAll Removes all ToolTip text currently associated with the ToolTip component.
Public method SetToolTip Associates ToolTip text with the specified control.
Public method Show(String, IWin32Window) Sets the ToolTip text associated with the specified control, and displays the ToolTip modally.
Public method Show(String, IWin32Window, Point) Sets the ToolTip text associated with the specified control, and then displays the ToolTip modally at the specified relative position.
Public method Show(String, IWin32Window, Int32) Sets the ToolTip text associated with the specified control, and then displays the ToolTip for the specified duration.
Public method Show(String, IWin32Window, Point, Int32) Sets the ToolTip text associated with the specified control, and then displays the ToolTip for the specified duration at the specified relative position.
Public method Show(String, IWin32Window, Int32, Int32) Sets the ToolTip text associated with the specified control, and then displays the ToolTip modally at the specified relative position.
Public method Show(String, IWin32Window, Int32, Int32, Int32) Sets the ToolTip text associated with the specified control, and then displays the ToolTip for the specified duration at the specified relative position.
Protected method StopTimer Stops the timer that hides displayed ToolTips.
Public method ToString Returns a string representation for this control. (Overrides Component.ToString().)
Top
  Name Description
Public event Disposed Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Public event Draw Occurs when the ToolTip is drawn and the OwnerDraw property is set to true and the IsBalloon property is false.
Public event Popup Occurs before a ToolTip is initially displayed. This is the default event for the ToolTip class.
Top

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 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.

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.

The following code example creates an instance of the ToolTip class and associates the instance with the Form that the instance is created within. The code then initializes the delay properties AutoPopDelay, InitialDelay, and ReshowDelay. In addition the instance of the ToolTip class sets the ShowAlways property to true to enable ToolTip text to always be display regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a Button and a CheckBox. The code example requires that the method defined in the example is located within a Form that contains a Button control named button1 and a CheckBox control named checkBox1, and that the method is called from the constructor of the Form.


      // This example assumes that the Form_Load event handling method
      // is connected to the Load event of the form.
      private void Form1_Load(object sender, System.EventArgs e)
      {
         // Create the ToolTip and associate with the Form container.
         ToolTip toolTip1 = new ToolTip();

         // Set up the delays for the ToolTip.
         toolTip1.AutoPopDelay = 5000;
         toolTip1.InitialDelay = 1000;
         toolTip1.ReshowDelay = 500;
         // Force the ToolTip text to be displayed whether or not the form is active.
         toolTip1.ShowAlways = true;
			
         // Set up the ToolTip text for the Button and Checkbox.
         toolTip1.SetToolTip(this.button1, "My button1");
         toolTip1.SetToolTip(this.checkBox1, "My checkBox1");
      }


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Tooltip extinguishes and doesn't come up anymore - Is Tooltip Windows not really hidden?
As it was already described in an earlier comment, I've got a tooltip displayed by a PictureBox and experience the same problem, no matter whether I use

myToolTip.SetToolTip(myPictureBox, myToolTipText);

or call the

ToolTip.Show Method (String, IWin32Window) from e.g. the MouseHover event in the PictureBox.

In both scenarios, if the mouse is held for a long time on the PictureBox, the tootip extinguishes after some time defined by AutoPopDelay and doesn't come up anymore on trying to leave and reenter the PictureBox again.

The following helps: Call

myToolTip.Hide(myPictureBox);

Then the tooltip will be displayed again as expected. This can be done during the PictureBox's MouseLeave event.

The problem behind the scenes seems to me although the ToolTip extinguishes after some time, its Window is not really hidden! This is why another Show() message has no effect.

And as a second effect: The Show() method should display the message infinitely until Hide() is called, but it doesn't appear to do so. Yes, it still does, but the ToolTip content gets invisible after sometime while the Windows itself stays present and is not hidden automatically.
the tooltips show up only once? try this
I have a bug on windows xp, mvs 2008 that the tooltips appear only once.
The solution may seems way stupid but it works (for me atleast)
just add the following 2 rows:

this.MyToolTip.Active = false;
this.MyToolTip.Active = true;

in the file MyForm.Designer.cs