Windows Forms 2.0 – The Tooltip Control

Posted by: Suprotim Agarwal , on 3/23/2007, in Category WinForms & WinRT
Views: 18621
Abstract: In this article, we will explore how to perform some common tasks using the Tooltip Control of Windows Forms 2.0.
Windows Forms 2.0 – The Tooltip Control
A ToolTip Control is a small rectangular pop-up window, that appears with an explanatory text when the user hovers the pointer over a control or window. A ToolTip can be associated with any control. Once this  component is added to a form, the other controls on that form get a special ToolTip property.
How Do I Get Started With The ToolTip Control
ToolTip text is not displayed for controls that are disabled.
With the ToolTip class, you can provide quick help to a user when the mouse rests on an item as shown in the Figure --- below. The SetToolTip method connects a tooltip with a control. Similarly to get the text that is associated with a control, use the GetToolTip method. The Tooltip control provides three important properties for Tooltip timing : AutoPopDelay, InitialDelay, and ReshowDelay. AutoPopDelay sets the period of time the ToolTip remains visible if the pointer is stationary on a control with specified ToolTip text. The InitialDelay sets the time that passes before the ToolTip appears. Reshow Delay sets the length of time that must transpire before subsequent ToolTip windows appear as the pointer moves from one control to another
The following code example creates an instance of the ToolTip class and associates the ToolTip text with a Button (btnDefaulttip). The code also initializes the delay properties AutoPopDelay, InitialDelay, and ReshowDelay.
private void CreateToolTip()
// Create default ToolTip
tip = new ToolTip();
// Set up the delays for the ToolTip.
tip.AutoPopDelay = 2000;
tip.InitialDelay = 500;
tip.ReshowDelay = 500;
// For Tooltip to be displayed irrespective of the the form being active/inactive set,
// tip.ShowAlways = true;
// Create btnDefaultTip and set initial values.
this.btnDefaultTip = new System.Windows.Forms.Button();
this.btnDefaultTip.Location = new System.Drawing.Point(56, 83);
this.btnDefaultTip.Size = new System.Drawing.Size(140, 23);
this.btnDefaultTip.Text = "Default";
// Set ToolTip for the button
tip.SetToolTip(btnDefaultTip, "A Button Tooltip");
Conclusion :
In this article, we took a quick overview of the Tooltip Control. I hope the article was useful and I thank you for viewing it.
What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Suprotim Agarwal, MCSD, MCAD, MCDBA, MCSE, is the founder of DotNetCurry, DNC Magazine for Developers, SQLServerCurry and DevCurry. He has also authored a couple of books 51 Recipes using jQuery with ASP.NET Controls and a new one recently at The Absolutely Awesome jQuery CookBook.

Suprotim has received the prestigious Microsoft MVP award for nine times in a row now. In a professional capacity, he is the CEO of A2Z Knowledge Visuals Pvt Ltd, a digital group that represents premium web sites and digital publications comprising of Professional web, windows, mobile and cloud developers, technical managers, and architects.

Get in touch with him on Twitter @suprotimagarwal, LinkedIn or befriend him on Facebook

Page copy protected against web site content infringement 	by Copyscape

Feedback - Leave us some adulation, criticism and everything in between!
Comment posted by swamy on Wednesday, September 2, 2009 2:43 AM
useful article, many thanks
Comment posted by prashanth on Saturday, June 5, 2010 10:44 AM
easy to make understand
thank you very much





Free DNC .NET Magazine



jQuery CookBook