Display tooltip on labels in windows forms

Niladri.Biswas
Posted by in Windows Forms category on for Beginner level | Points: 250 | Views : 8520 red flag

In this article we will look into as how to display tooltip on labels.


 Download source code for Display tooltip on labels in windows forms

Introduction

The label control in windows forms doesn't have any tool tip property.However, in certain cases we may need to show the tool tip in label.In this article we will look into as how to display tool tip on labels.

Straight to experiment

We will discuss two aspects as how to set tool tip - one at design time and the other dynamically.

Add tooltip at design time

First of all select the ToolTip control

Then add the ToolTip control on to the form

Then drag and drop a label control and we will find the tooltip property

Write something and then run the application

Add tool tip dynamically

Add a label control to the form.Then in the form load event write the below code

private void Form1_Load(object sender, EventArgs e)
{
	System.Windows.Forms.ToolTip tooltip = new System.Windows.Forms.ToolTip();
	tooltip.IsBalloon = true;
	tooltip.ShowAlways = true;
	tooltip.SetToolTip(label2, "This is a dynamic tooltip");

}

This will display a balloon tooptip on the label2 whose content is set dynamically.

Conclusion

So this article has demonstrated as how to add tool tip to label controls.The same is applicable for other controls also.Hope this will be helpful.Thanks for reading.Zipped file is attached.

Page copy protected against web site content infringement by Copyscape

About the Author

Niladri.Biswas
Full Name: Niladri Biswas
Member Level: Platinum
Member Status: Member
Member Since: 10/25/2010 11:04:24 AM
Country: India
Best Regards, Niladri Biswas
http://www.dotnetfunda.com
Technical Lead at HCL Technologies

Login to vote for this post.

Comments or Responses

Posted by: jnrprogrammer-22113 on: 8/29/2013 | Points: 25
Hi,

I am using web forms and i have tried to apply this code on text box on my aspx page but it gives error

System.Windows.Forms.ToolTip tooltip = new System.Windows.Forms.ToolTip();
tooltip.IsBalloon = true;
tooltip.ShowAlways = true;
tooltip.SetToolTip(txtComments, "This is a dynamic tooltip");

Can you please help....

Thanks..

Login to post response

Comment using Facebook(Author doesn't get notification)