How do I add a ToolTip to a control?

Svish picture Svish · Aug 27, 2009 · Viewed 180.3k times · Source

I have some controls that I would like to display a ToolTip for when the mouse is hovering over it. How can I do this? I would like to know how to do this properly in code, but also in the designer (There is a ToolTip component in the toolbox, but I don't quite.. get it).

I wouldn't be surprised if this is a duplicate, but I can only find questions that are on more advanced, specific scenarios. I would like to know the basics.

Answer

Svetlozar Angelov picture Svetlozar Angelov · Aug 27, 2009

Here is your article for doing it with code

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");
}