Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • C# Data Types
  • C# Decision Making
  • C# Methods
  • C# Delegates
  • C# Constructors
  • C# Arrays
  • C# ArrayList
  • C# String
  • C# Tuple
  • C# Indexers
  • C# Interface
  • C# Multithreading
  • C# Exception
Open In App
Next Article:
How to set AutoPopDelay of ToolTip in C#?
Next article icon

C# | ToolTip Class

Last Updated : 10 Aug, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

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.


Next Article
How to set AutoPopDelay of ToolTip in C#?
author
ankita_saini
Improve
Article Tags :
  • C#
  • CSharp-Windows-Forms-Namespace

Similar Reads

  • 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 tra
    3 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 us
    3 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 wi
    3 min read
  • 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
    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
    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 ToolT
    4 min read
  • Hello World Program : First program while learning Programming
    In this article, I'll show you how to create your first Hello World computer program in various languages. Along with the program, comments are provided to help you better understand the terms and keywords used in theLearning program. Programming can be simplified as follows: Write the program in a
    6 min read
  • Java Swing | ToolTip
    We can add tooltip text to almost all the components of Java Swing by using the following method setToolTipText(String s). This method sets the tooltip of the component to the specified string s. When the cursor enters the boundary of that component a popup appears and text is displayed. Methods use
    4 min read
  • ToDo App in C Language
    ToDo List App is a kind of app that generally used to maintain our day-to-day tasks or list everything that we have to do, with the most important tasks at the top of the list, and the least important tasks at the bottom. It is helpful in planning our daily schedules. We can add more tasks at any ti
    10 min read
  • How to change cursor style using C
    In this article, we will discuss how to change the cursor style on the screen in C. Approach: The idea is to use the setcursortype() function to change the cursor style on the output screen. This function takes cursor-type as an argument and is declared under the conio.h header file. Header File: #i
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences