Monday, May 17, 2004

I was looking for something that I could create to use a tooltip on a textbox.  Sometimes this can be very handy.  I have a little project where I need this tool tip for extra information to the user.

 

In .net this is easy because under the windows.forms namespace you got the tool tip object.

The best way to add tooltips on your form is to create the tool tip object in your form_load event.

 

These are the steps :

  •             Declare a new tooltip object
  •             In the form_load event set the tooltip for every control you want.  You can set all properties here

Public Class Form1
Inherits System.Windows.Forms.Form

Private oTooltip As New ToolTip

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
oTooltip.SetToolTip(TextBox1, "Meerder adressen scheiden door ;")
oTooltip.ShowAlways =
True
End Sub

End Class

You need also to remove those tool tips when closing your form.  In the closing event you could use the remove_all method to delete your tool tips.

 

oTooltip.RemoveAll()

 

The tooltip has some nice properties :

            AutoPopDelay : Sets the time that the tool tip remains visible.

            ShowAlways : shows the tool tip even when the control isn't active

 

Update :
If you want to do it the easy way.  Just drop the tool tip control on your form.  When asking the properties of the other controls on your form, you will see that they have a new property 'ToolTip on ToolTip1'.  This can be used to show the tool tip text.  All the properties of the tool tip component can be set by using the properties of the tool tip component. (Thanks Raf)

5/17/2004 2:02:33 PM (Romance Standard Time, UTC+01:00)  #     |