ToolTip Control in F#


In this article I have explained the ToolTip Control and how to use this control in a Windows Forms application. The ToolTip Control is generally used for displaying the textual information when the user rolls over the control.

ToolTip Control

The ToolTip Control is generally used for providing the contextual hints to the users while users hover the mouse over the control. The ToolTip class provides the ToolTip control. The ToolTip class is used for alerting users to the intended use of a control. You can specify text for the TextBox control indicating the accept specific format of the data to be typed into the control. The ToolTip control can display a single line text or multiple lines of text at a time. Balloon ToolTips texts are displayed in a box with rounded corners; they can be either single line or multiple lines. The maximum length for the standard tooltip text is 80 characters.

Namespace: System.Windows.Forms.Tooltip

Note: The ToolTip text is not displayed for a control that is disabled unless the ShowAlways property is set to true. ToolTips are not displayed when their container is inactive.


let tip=new ToolTip(ToolTipTitle="Use ToolTip",IsBalloon=true,ToolTipIcon=ToolTipIcon.Info)


Properties of ToolTip Control

  •  SetToolTip : Title of the tooltip window.

  •  ToolTipIcon : Icon of the tooltip window.

  •  IsBalloon : Gets or sets whether the tooltip is shown in the balloon shape.

  •  Active Property : It means the tooltip control is active.

  • BackColor and Forecolor : Gets or sets the background color for the tooltip window.

  • AutomaticDelay : This property allows you to specify the number of milliseconds after the user hovers overs the tooltip before its shown.

Now let's use the following procedure.

Step 1:

Open Visual Studio then select "Create New Project" --> "F# Console Application".


Step 2:

Now go the Solution Explorer on the right side of the application. Right-click on "References" and select "Add references".



Step 3:

After selecting "Add References", in the framework template you need to select "System.Windows.Forms", "System.Drawing", "System.Data" and "System.Data.SqlClient" while holding down the Ctrl key and click on "Ok."


Step 4:

Write the following code for the F# application.

// Learn more about F# at


open System   

open System.Drawing   

open System.Data

open System.Data.SqlClient

open System.Windows.Forms  

let UserForm = new Form(Height =400, Width = 500)

let tip=new ToolTip(ToolTipTitle="Use ToolTip",IsBalloon=true,ToolTipIcon=ToolTipIcon.Info)

//   Labels

let lblId = new Label(Top =20 , Height =30, Width = 50)

let lblName = new Label(Top =50 , Height =30, Width = 100)

let lblLname = new Label(Top =80 , Height =30, Width = 100)

let lblSalary = new Label(Top =110 , Height =30, Width = 50)

let lblAddress = new Label(Top =140 , Height =30, Width = 50)

let lblCity = new Label(Top =170, Height =30, Width = 50)

//   TextBoxes

let txtId = new TextBox(Top =20, Left =120)

let txtName = new TextBox(Top =50, Left =120)

let txtLname = new TextBox(Top =80, Left =120)

let txtSalary = new TextBox(Top =110,Left=120)

let txtAddress = new TextBox(Top =140,Left=120)

let txtCity = new TextBox(Top =170,Left=120)

lblId.Text <- "ID:"

lblName.Text <- "First Name :"

lblLname.Text <- "Last Name :"

lblSalary.Text <- "Salary"

lblAddress.Text <- "Address"

lblCity.Text <- "City"

let btnSave = new Button(Top =200, Left =80, Height =30, Width =60)

btnSave.Text <- "Submit"

let btnreset = new Button(Top =200, Left =160, Height =30, Width =60)

btnreset.Text <- "Reset"

//Adding Controls to Form















//Adding Tooltip

txtId.MouseHover.Add(fun tipmsg-> 

tip.SetToolTip(txtId,"Enter UserId Here"))

txtName.MouseHover.Add(fun tipmsg-> 

tip.SetToolTip(txtName,"Enter FirstName Here"))

txtLname.MouseHover.Add(fun tipmsg-> 

tip.SetToolTip(txtLname,"Enter LastName Here"))

txtSalary.MouseHover.Add(fun tipmsg-> 

tip.SetToolTip(txtSalary,"Enter Salary Here"))

txtAddress.MouseHover.Add(fun tipmsg-> 

tip.SetToolTip(txtAddress,"Enter Address Here"))

txtCity.MouseHover.Add(fun tipmsg-> 

tip.SetToolTip(txtCity,"Enter City Here"))

btnSave.MouseHover.Add(fun tipmsg-> 

tip.SetToolTip(btnSave,"Click here to Save the records"))

btnreset.MouseHover.Add(fun tipmsg-> 

tip.SetToolTip(btnreset,"Click here to Reset the textboxes"))

//run the application



Step 5:

Debug the application by pressing F5 and the result will appear in the application as in the following figure.


Step 6:.


Step 7:


Step 8:


Step 9:



In this article, we have explained how to create and use a ToolTip control. First we explained how to create a ToolTip Control in Windows Forms application and the properties of a ToolTip Control.