How can I display a tooltip over a button using Windows Forms?
-
13Following article best explains it with visuals: [http://www.dotnetperls.com/tooltip](http://www.dotnetperls.com/tooltip) – vaichidrewar May 03 '11 at 17:02
10 Answers
The ToolTip is a single WinForms control that handles displaying tool tips for multiple elements on a single form.
Say your button is called MyButton.
- Add a ToolTip control (under Common Controls in the Windows Forms toolbox) to your form.
- Give it a name - say MyToolTip
- Set the "Tooltip on MyToolTip" property of MyButton (under Misc in the button property grid) to the text that should appear when you hover over it.
The tooltip will automatically appear when the cursor hovers over the button, but if you need to display it programmatically, call
MyToolTip.Show("Tooltip text goes here", MyButton);
in your code to show the tooltip, and
MyToolTip.Hide(MyButton);
to make it disappear again.

- 8,018
- 9
- 64
- 107

- 53,688
- 35
- 128
- 197
-
nice, but a question: if I have more than one button in a form, I need more tooltip or I can set multiple descriptions and buttons for the same tooltip? – ghiboz Apr 23 '14 at 17:24
-
9Your form only needs a single ToolTip control - each button can have different help text (this is why the "Tooltip on MyToolTip" is a property of the associated control, not of the ToolTip control itself) – Dylan Beattie Apr 23 '14 at 18:15
-
3In the simplest case adding the tooltip to the Form is the best thing to do. Problem: at design time of a custom Control you have no reference to parent Form. Solution: create a tooltip object in the Control. Don't think of the ToolTip object as necessarily attached to the Form. – Stéphane Gourichon Jul 08 '14 at 06:27
Using the form designer:
- Drag the ToolTip control from the Toolbox, onto the form.
- Select the properties of the control you want the tool tip to appear on.
- Find the property 'ToolTip on toolTip1' (the name may not be toolTip1 if you changed it's default name).
- Set the text of the property to the tool tip text you would like to display.
You can set also the tool tip programatically using the following call:
this.toolTip1.SetToolTip(this.targetControl, "My Tool Tip");
You can use the ToolTip class:
Creating a ToolTip for a Control
Example:
private void Form1_Load(object sender, System.EventArgs e)
{
System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
ToolTip1.SetToolTip(this.Button1, "Hello");
}

- 4,509
- 3
- 33
- 33
-
2This is the perfect solution as it integrates directly with the auto generated VS code. Thanks :) – fIwJlxSzApHEZIl Oct 24 '12 at 00:03
-
@DaveK Thanks. Is better this way because I can define all the tooltips on one place – fedeteka Jan 16 '17 at 19:11
-
-
1
For default tooltip this can be used -
System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
ToolTip1.SetToolTip(this.textBox1, "Hello world");
A customized tooltip can also be used in case if formatting is required for tooltip message. This can be created by custom formatting the form and use it as tooltip dialog on mouse hover event of the control. Please check following link for more details -
http://newapputil.blogspot.in/2015/08/create-custom-tooltip-dialog-from-form.html

- 484
- 9
- 15
The .NET framework provides a ToolTip class. Add one of those to your form and then on the MouseHover event for each item you would like a tooltip for, do something like the following:
private void checkBox1_MouseHover(object sender, EventArgs e)
{
toolTip1.Show("text", checkBox1);
}

- 5,178
- 14
- 52
- 78

- 15,459
- 7
- 44
- 62
Lazy and compact storing text in the Tag property
If you are a bit lazy and do not use the Tag property of the controls for anything else you can use it to store the tooltip text and assign MouseHover event handlers to all such controls in one go like this:
private System.Windows.Forms.ToolTip ToolTip1;
private void PrepareTooltips()
{
ToolTip1 = new System.Windows.Forms.ToolTip();
foreach(Control ctrl in this.Controls)
{
if (ctrl is Button && ctrl.Tag is string)
{
ctrl.MouseHover += new EventHandler(delegate(Object o, EventArgs a)
{
var btn = (Control)o;
ToolTip1.SetToolTip(btn, btn.Tag.ToString());
});
}
}
}
In this case all buttons having a string in the Tag property is assigned a MouseHover event. To keep it compact the MouseHover event is defined inline using a lambda expression. In the event any button hovered will have its Tag text assigned to the Tooltip and shown.

- 5,178
- 14
- 52
- 78

- 1,123
- 13
- 9
private void Form1_Load(object sender, System.EventArgs e)
{
ToolTip toolTip1 = new ToolTip();
toolTip1.AutoPopDelay = 5000;
toolTip1.InitialDelay = 1000;
toolTip1.ReshowDelay = 500;
toolTip1.ShowAlways = true;
toolTip1.SetToolTip(this.button1, "My button1");
toolTip1.SetToolTip(this.checkBox1, "My checkBox1");
}

- 6,313
- 15
- 32
- 40

- 39
- 1
-
4While this code snippet may solve the question, [including an explanation](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – secelite Mar 01 '18 at 16:30
Based on DaveK's answer, I created a control extension:
public static void SetToolTip(this Control control, string txt)
{
new ToolTip().SetToolTip(control, txt);
}
Then you can set the tooltip for any control with a single line:
this.MyButton.SetToolTip("Hello world");

- 5,178
- 14
- 52
- 78
-
1Don't do this. The ToolTip control needs to be disposed and this creates an orphan instance that never gets disposed every time it's called. This extension method leaks system resources. – Joel Mueller Jul 19 '21 at 19:58
-
@Joel Mueller, Indeed it would be a better practice to dispose the previous instance but since the ToolTip would become unreferenced, wouldn't it be [collected by the GC](https://stackoverflow.com/questions/1955390/c-sharp-memory-and-dispose-related-questions/1955500#1955500)? If it doesn't, then yes, I think my answer shouldn't be used as is. – The_Black_Smurf Jul 20 '21 at 13:50
I have done the cool tool tip Code is:
1.Initialize the tooltip object
2.call the object when or where you want to displays your creativity
Ex-
ToolTip t=new ToolTip();
t.setToolTip(textBoxName,"write your message here what tp you want to show up");

- 4,704
- 13
- 34
- 52
Sure, just handle the mousehover event and tell it to display a tool tip. t is a tooltip defined either in the globals or in the constructor using:
ToolTip t = new ToolTip();
then the event handler:
private void control_MouseHover(object sender, EventArgs e)
{
t.Show("Text", (Control)sender);
}

- 4,106
- 9
- 38
- 51
-
2I think you got voted down because that's not the way to use ToolTip controls in Windows Forms. You only need one such control on the form and it shows the tips for all the controls. See code in the other responses. – Julian Melville Jun 09 '09 at 05:32
-
1I guess the explanation doesn't match the code, Where in the explanation I said do display it and in the code I initialized it as well. My bad. :P – Fry Sep 16 '09 at 00:19
-
2@ julianz Actually, this works well for having specialized tooltips which can be dynamic if you want depending on state (minus of course the creation - forgive me, I was just trying to fit it all into one block.) As for other responses on a similar vein... yshuditelu and Dylan Beattie were similar albeit without the instantiation. – Fry Sep 16 '09 at 00:29