How to set automatic delay for ToolTip in C#?
In Windows Forms, the ToolTip represents a tiny pop-up box which appears when you place your pointer or cursor on the control and the purpose of this control is it provides a brief description about the control present in the windows form. In ToolTip, you can set the automatic delay for the ToolTip using AutomaticDelay Property.
This property allows you to set a solo delay values for the AutoPopDelay, InitialDelay, and ReshowDelay properties. Whenever the value of AutomaticDelay property, then the following values set by default:
- For AutoPopDelay property: The default value is 10 times the value of AutomaticDelay property.
- For InitialDelay property: The default value is equal to the value of the AutomaticDelay property.
- For ReshowDelay property: The default value is 1/5 of the value of the AutomaticDelay property.
The values of these properties can also be set independently. You can set this property in two different ways:
1. Design-Time: It is the easiest way to set the value of the AutomaticDelay property as shown in the following steps:
- Step 1: Create a windows form as shown in the below image:
Visual Studio -> File -> New -> Project -> WindowsFormApp

- Step 2: Drag the ToolTip from the ToolBox and drop it on the form. When you drag and drop this ToolTip on the form it will automatically add to the properties(named as ToolTip on ToolTip1) of every controls present in the current windows from.

- Step 3: After drag and drop you will go to the properties of the ToolTip and set the value of the AutomaticDelay property.
Output:

2. Run-Time: It is a little bit trickier than the above method. In this method, you can set the AutomaticDelay property of ToolTip programmatically with the help of given syntax:
public int AutomaticDelay { get; set; }
Here, the value of this property is of System.Int32 type and the delay is always in milliseconds. The default value of this property is 500. The following steps show how to set the AutomaticDelay property of the ToolTip dynamically:
- Step 1: Create a ToolTip using the ToolTip() constructor is provided by the ToolTip class.
// Creating a ToolTip ToolTip t = new ToolTip();
- Step 2: After creating Tooltip, set the AutomaticDelay property of the Tooltip provided by the ToolTip class.
// Setting the AutomaticDelay property t.AutomaticDelay = 600;
- Step 3: And last add this ToolTip to the controls using SetToolTip() method. This method contains the control name and the text which you want to display in the ToolTip box.
t.SetToolTip(box1, "Name should start with Capital letter");
Example:
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespaceWindowsFormsApp34 {publicpartialclassForm1 : Form {publicForm1(){InitializeComponent();}privatevoidForm1_Load(objectsender, EventArgs e){// Creating and setting the// properties of the LabelLabel l1 =newLabel();l1.Location =newPoint(140, 122);l1.Text ="Name";// Adding this Label// control to the formthis.Controls.Add(l1);// Creating and setting the// properties of the TextBoxTextBox box1 =newTextBox();box1.Location =newPoint(248, 119);box1.BorderStyle = BorderStyle.FixedSingle;// Adding this TextBox// control to the formthis.Controls.Add(box1);// Creating and setting// the properties of the LabelLabel l2 =newLabel();l2.Location =newPoint(140, 152);l2.Text ="Password";// Adding this Label// control to the formthis.Controls.Add(l2);// Creating and setting the// properties of the TextBoxTextBox box2 =newTextBox();box2.Location =newPoint(248, 145);box2.BorderStyle = BorderStyle.FixedSingle;// Adding this TextBox// control to the formthis.Controls.Add(box2);// Creating and setting the// properties of the ToolTipToolTip t =newToolTip();t.Active =true;t.AutoPopDelay = 4000;t.InitialDelay = 600;t.IsBalloon =true;t.ToolTipIcon = ToolTipIcon.Info;t.ToolTipTitle ="Important";t.AutomaticDelay = 600;t.SetToolTip(box1,"Name should start with Capital letter");t.SetToolTip(box2,"Password should be greater than 8 words");}}}chevron_rightfilter_noneOutput:

Recommended Posts:
- How to set AutoPopDelay of ToolTip in C#?
- How to set ToolTip to active in C#?
- How to set the initial delay of the ToolTip in C#?
- How to make a balloon ToolTip window in C#?
- How to set the title of the ToolTip in C#?
- How to set icon in the ToolTip in C#?
- How to set Reshow Delay for ToolTip in C#?
- C# | ToolTip Class
- Hello World Program : First program while learning Programming
- Range and Indices in C# 8.0
- Range Structure in C# 8.0
- Basics Operations of File and Directory in C#
- Check if the given ranges are equal or not in C#
- How to Create a Range to a Specified End in C#?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


