The Wayback Machine - https://web.archive.org/web/20240906230719/https://www.geeksforgeeks.org/c-sharp-tooltip-class/
Open In App

C# | ToolTip Class

Last Updated : 10 Aug, 2022
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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. The ToolTip class is used to create ToolTip control and also provide different types of properties, methods, events and also provides run time status of the controls. You are allowed to use a ToolTip class in any container or control. With the help of a single ToolTip component, you are allowed to create multiple tooltips for multiple controls. the ToolTip class defined under System.Windows.Forms namespace. In C# you can create a ToolTip in the windows form by using two different ways: 1. Design-Time: It is the easiest way to create a ToolTip 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 control to modify ToolTip according to your requirement. Output:

2. Run-Time: It is a little bit trickier than the above method. In this method, you can create a ToolTip control programmatically with the help of syntax provided by the ToolTip class. The following steps show how to set the create ToolTip dynamically:

  • Step 1: Create a ToolTip control using the ToolTip() constructor is provided by the ToolTip class.
// Creating a ToolTip control
ToolTip t_Tip = new ToolTip(); 
  • Step 2: After creating ToolTip control, set the property of the ToolTip control provided by the ToolTip class.
// Setting the properties of ToolTip
t_Tip.Active = true; 
t_Tip.AutoPopDelay = 4000; 
t_Tip.InitialDelay = 600; 
t_Tip.IsBalloon = true; 
t_Tip.ToolTipIcon = ToolTipIcon.Info; 
t_Tip.SetToolTip(box1, "Name should start with Capital letter"); 
t_Tip.SetToolTip(box2, "Password should be greater than 8 words"); 
  • Example: 

CSharp




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace WindowsFormsApp34 {
 
public partial class Form1 : Form {
 
    public Form1()
    {
        InitializeComponent();
    }
 
    private void Form1_Load(object sender, EventArgs e)
    {
        // Creating and setting the
        // properties of the Label
        Label l1 = new Label();
        l1.Location = new Point(140, 122);
        l1.Text = "Name";
 
        // Adding this Label
        // control to the form
        this.Controls.Add(l1);
 
        // Creating and setting the
        // properties of the TextBox
        TextBox box1 = new TextBox();
        box1.Location = new Point(248, 119);
        box1.BorderStyle = BorderStyle.FixedSingle;
 
        // Adding this TextBox
        // control to the form
        this.Controls.Add(box1);
 
        // Creating and setting the
        // properties of Label
        Label l2 = new Label();
        l2.Location = new Point(140, 152);
        l2.Text = "Password";
 
        // Adding this Label
        // control to the form
        this.Controls.Add(l2);
 
        // Creating and setting the
        // properties of the TextBox
        TextBox box2 = new TextBox();
        box2.Location = new Point(248, 145);
        box2.BorderStyle = BorderStyle.FixedSingle;
 
        // Adding this TextBox
        // control to the form
        this.Controls.Add(box2);
 
        // Creating and setting the
        // properties of the ToolTip
        ToolTip t_Tip = new ToolTip();
        t_Tip.Active = true;
        t_Tip.AutoPopDelay = 4000;
        t_Tip.InitialDelay = 600;
        t_Tip.IsBalloon = true;
        t_Tip.ToolTipIcon = ToolTipIcon.Info;
        t_Tip.SetToolTip(box1, "Name should start with Capital letter");
        t_Tip.SetToolTip(box2, "Password should be greater than 8 words");
    }
}
}


  • Output:

Constructor

.ToolTip-table { border-collapse: collapse; width: 100%; } .ToolTip-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .ToolTip-table th { border: 1px solid #5fb962; padding: 8px; } .ToolTip-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .ToolTip-table tr:nth-child(odd) { background-color: #ffffff; } 

Constructor Description
ToolTip() This Constructors is used to initialize a new instance of the ToolTip without a specified container.
ToolTip(IContainer) This Constructors is used to initialize a new instance of the ToolTip class with a specified container.

Properties

Property Description
Active This property is used to get or set a value indicating whether the ToolTip is currently active.
AutomaticDelay This property is used to get or set the automatic delay for the ToolTip.
AutoPopDelay This property is used to get or set the period of time the ToolTip remains visible if the pointer is stationary on a control with specified ToolTip text.
BackColor This property is used to get or set the background color for the control.
ForeColor This property is used to get or set the foreground color of the control.
InitialDelay This property is used to get or set the time that passes before the ToolTip appears.
IsBalloon This property is used to get or set a value indicating whether the ToolTip should use a balloon window.
ReshowDelay This property is used to get or set the length of time that must transpire before subsequent ToolTip windows appear as the pointer moves from one control to another.
ToolTipIcon This property is used to get or set a value that defines the type of icon to be displayed alongside the ToolTip text.
ToolTipTitle This property is used to get or set a title for the ToolTip window.


Similar Reads

How to set AutoPopDelay of 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 are allowed to set the time period in which the ToolTip remains visible when the pointer or cu
4 min read
How to set ToolTip to active 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 check the ToolTip is active or not by using Active Property. The default value of this pro
3 min read
How to set the initial delay of the 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 are allowed to set the time passes before the ToolTip box pop-up by using InitialDelay Propert
4 min read
How to make a balloon ToolTip window 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 are allowed to change the shape of the ToolTip window by using IsBalloon Property. With the he
4 min read
How to set the title of the 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 are allowed to set the title in the ToolTip window which displays on the screen using ToolTipT
4 min read
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 allow
4 min read
How to set icon in the 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 are allowed to set an icon in the ToolTip window with ToolTip text using ToolTipIcon Property.
3 min read
How to set Reshow 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 length of the time that must transpire before subsequent ToolTip windows appear as
3 min read
C# Program to Inherit an Abstract Class and Interface in the Same Class
Abstract Class is the way to achieve abstraction. It is a special class that never be instantiated directly. This class should contain at least one abstract method in it and mark by abstract keyword in the class definition. The main purpose of this class is to give a blueprint for derived classes and set some rules what the derived classes must imp
3 min read
C# | How to get TypeCode for the class String
GetTypeCode() method is used to get the TypeCode of the specified string. Here TypeCode enum represents a specific type of object. In TypeCode every data type is represented by a specific number like String is represented by 18, Int32 is represented by 9, etc. Syntax: public TypeCode GetTypeCode (); Return value: This method return an enumerated co
2 min read
C# | Class and Object
Class and Object are the basic concepts of Object-Oriented Programming which revolve around the real-life entities. A class is a user-defined blueprint or prototype from which objects are created. Basically, a class combines the fields and methods(member function which defines actions) into a single unit. In C#, classes support polymorphism, inheri
5 min read
C# | Sealed Class
Sealed classes are used to restrict the users from inheriting the class. A class can be sealed by using the sealed keyword. The keyword tells the compiler that the class is sealed, and therefore, cannot be extended. No class can be derived from a sealed class. The following is the syntax of a sealed class : sealed class class_name { // data members
4 min read
C# | Math Class Fields with Examples
In C#, the Math class provides the constants and the static methods for logarithmic, trigonometric, and other mathematical functions. Math class has two fields as follows: Math.E FieldMath.PI FieldMath.E Field This field represents the natural logarithmic base, specified by the constant, e. Syntax: public const double E Program 1: To illustrate the
3 min read
C# | Math Class
In C#, Math class comes under the System namespace. It is used to provide static methods and constants for logarithmic, trigonometric, and other useful mathematical functions. It is a static class and inherits the object class. public static class Math Fields A field is a variable that is declared in a class or struct. These are considered as the m
4 min read
C# | List Class
.list-table { border-collapse: collapse; width: 100%; } .list-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .list-table th { border: 1px solid #5fb962; padding: 8px; } .list-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .list-table tr:nth-child(odd) { background-color: #ffffff; } List<T
7 min read
C# | ListDictionary Class
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } ListDictiona
5 min read
C# | HybridDictionary Class
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } HybridDictio
5 min read
C# | ArrayList Class
.arraylist-table { border-collapse: collapse; width: 100%; } .arraylist-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .arraylist-table th { border: 1px solid #5fb962; padding: 8px; } .arraylist-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .arraylist-table tr:nth-child(odd) { background-color
7 min read
C# | BitArray Class
.bitarray-table { border-collapse: collapse; width: 100%; } .bitarray-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .bitarray-table th { border: 1px solid #5fb962; padding: 8px; } .bitarray-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .bitarray-table tr:nth-child(odd) { background-color: #ff
6 min read
C# | StringDictionary Class
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } StringDictio
5 min read
C# | OrderedDictionary Class
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } OrderedDicti
5 min read
C# | String class
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } In C#, a str
9 min read
C# | SortedSet Class
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } SortedSet cl
6 min read
C# | StringCollection Class
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } StringCollec
5 min read
C# | Creating an empty case-sensitive HybridDictionary Class
HybridDictionary() creates an empty case-sensitive HybridDictionary. Syntax: public HybridDictionary (); Below given are some examples to understand the implementation in a better way: Example 1: C/C++ Code // C# code to create an empty // case-sensitive HybridDictionary. using System; using System.Collections; using System.Collections.Specialized;
2 min read
C# | LinkedList Class
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } LinkedList
5 min read
C# | Collection Class
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } Collection
5 min read
C# | HashSet Class
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } A HashSet
6 min read
C# | SortedList Class
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } SortedList c
6 min read
C# | Hashtable Class
The Hashtable class represents a collection of key/value pairs that are organized based on the hash code of the key. This class comes under the System.Collections namespace. The Hashtable class provides various types of methods that are used to perform different types of operation on the hashtables. In Hashtable, keys are used to access the element
7 min read