Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMake tooltips remain visible for a very long time in Visual Basic .NET
DescriptionThis example shows how to make tooltips remain visible for a very long time in Visual Basic .NET.
Keywordstooltip, tool tip, Visual Basic .NET, VB.NET
CategoriesControls, VB.NET, Software Engineering
 
The ToolTip control's AutoPopDelay property determines how long a tooltip remains visible. Unfortunately the tooltip seems to go away after about 7 seconds regardless.

If you float the mouse over the top row of buttons, the program displays a normal tooltip. AutoPopDelay is set to 3600000 (1 hour) but the tooltip goes away after around 7 seconds.

The program uses the following code to display tooltips for the second row of buttons. When the mouse enters a button, the code calls the ToolTip's GetToolTip method to get the control's tooltip. It then calls the Show method to display the tooltip for an hour. This seems to work.

 
Private Sub Button_ShowTip(ByVal sender As Object, ByVal e _
    As System.EventArgs) Handles Button4.MouseEnter, _
    Button5.MouseEnter, Button6.MouseEnter
    Dim btn As Button = DirectCast(sender, Button)
    Dim txt As String = ToolTip1.GetToolTip(btn)
    ToolTip1.Show(txt, btn, 3600000)
End Sub
 
If the user really needs to always see instructions about a control, however, you might be better off displaying it in a Label or somewhere other than a tooltip. When you float the mouse over one of the bottom buttons, the following code displays the text in the button's Tag property in a label. When the mouse leaves the button, the code clears the label.
 
Private Sub Button_ShowLabel(ByVal sender As Object, ByVal _
    e As System.EventArgs) Handles Button7.MouseEnter, _
    Button8.MouseEnter, Button9.MouseEnter
    Dim btn As Button = DirectCast(sender, Button)
    Dim txt As String = btn.Tag
    If lblTip.Text <> txt Then lblTip.Text = txt
End Sub

Private Sub Button_ClearLabel(ByVal sender As Object, ByVal _
    e As System.EventArgs) Handles Button7.MouseLeave, _
    Button8.MouseLeave, Button9.MouseLeave
    If lblTip.Text <> "" Then lblTip.Text = ""
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated