Tooltips and Linklabels
A reader wrote to ask ...
"I use hundreds of web links in my Windows Forms application and I would love to have mouse over 'explanations' of the links."
We can do that!
If you have coded HTML, you might have used little Javascript programs triggered by onmouseover or onmouseout to do things. You can do the same thing with VB.NET using the Tooltip class.
Tooltips go back to VB6, but the way they work has changed completely in .NET. (What hasn't?) In VB6, controls have a ToolTipText property. At runtime, if the property isn't empty, the text is displayed.
In VB.NET, a Tooltip is an object like everything else in .NET. So you have to declare the object and then associate the Tooltip with the text and the control. It works like this:
Dim AVBToolTip As New ToolTip()
AVBToolTip.SetToolTip(control, "A GREAT Source for VB Info!")
The control that displays the Tooltip doesn't have a "tooltip" property like VB6. The text is assigned to the control using the SetToolTip method instead. Usually, this code will be placed where initialization is done such as the Load event for the form. One of the advantages is that now there are a lot of other properties and methods for the Tooltip such as:
AVBToolTip.AutoPopDelay = 3000
AVBToolTip.InitialDelay = 500
AVBToolTip.ReshowDelay = 500
AVBToolTip.ShowAlways = True
You can assign a Tooltip to the LinkLabel control to display links on a form. The LinkLabel is so flexible that I wrote a complete article on just that one component: The VB.NET LinkLabel.


Comments
No comments yet. Leave a Comment