Tooltip Control in VB.NET

In this article, I will discuss how to create and use a Tooltip control in a Windows Forms application using Visual Studio 2010. After that, I will discuss various properties and methods available for the Tooltip control.
  • 34630

tooltip is a small pop-up window that displays some information when you rollover on a control.

In this article, I will discuss how to create and use a Tooltip control in a Windows Forms application using Visual Studio 2010. After that, I will discuss various properties and methods available for the Tooltip control.

Creating a Tooltip

Tooltip class represents a tooltip control. Once a Tooltip object is created, we need to call SetToolTip method and pass a control and text. The following code snippet creates a Tooltip and attach to a Button control using SetToolTip method.

Dim toolTip1 As New ToolTip()

toolTip1.ShowAlways = True

toolTip1.SetToolTip(button1, "Click me to execute.")

If you rollover on Button control, you will see the following output.

 

ToolTipImg1.jpg
Figure 1

Tooltip Properties

·         Active - A tooltip is currently active.

·         AutomaticDelay - Automatic delay for the tooltip.

·         AutoPopDelay - The period of time the ToolTip remains visible if the pointer is stationary on a control with specified ToolTip text.

·         InitialDelay - Gets or sets the time that passes before the ToolTip appears.

·         IsBaloon  - Gets or sets a value indicating whether the ToolTip should use a balloon window.

·         ReshowDelay - Gets or sets the length of time that must transpire before subsequent ToolTip windows appear as the pointer moves from one control to another.

·         ShowAlways - Displays if tooltip is displayed even the parent control is not active.

·         ToolTipIcon - Icon of tooltip window.

·         ToolTipTitle - Title of tooltip window.

·         UseAnimation - Represents weather an animation effect should be used when displaying the tooltip.

·         UseFading - Represents weather a fade effect should be used when displaying the tooltip.

The following code snippet sets some of these properties.

Dim buttonToolTip As New ToolTip()

buttonToolTip.ToolTipTitle = "Button Tooltip"

buttonToolTip.UseFading = True

buttonToolTip.UseAnimation = True

buttonToolTip.IsBalloon = True

buttonToolTip.ShowAlways = True

buttonToolTip.AutoPopDelay = 5000

buttonToolTip.InitialDelay = 1000

buttonToolTip.ReshowDelay = 500

buttonToolTip.IsBalloon = True

buttonToolTip.SetToolTip(Button1, "Click me to execute.")

Balloon Tooltip

By setting IsBalloon to true makes a tooltip balloon that looks like Figure 2.

ToolTipImg2.jpg
Figure 2

Summary

In this article, we discussed discuss how to create a Tooltip control in Windows Forms and set its various properties.

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.