devxlogo

ListBoxTooltip – A class for displaying items’ values in a tooltip

ListBoxTooltip – A class for displaying items’ values in a tooltip

' --- The ListBoxTooltip class'' Usage in the client form:''    Dim lstTT As New ListBoxTooltip''    Private Sub Form_Load()'        Set lstTT.ListBox = List1'      End Sub'    Private Sub Form_Unload(Cancel As Integer)'        Set lstTT.ListBox = Nothing'    End SubPublic WithEvents ListBox As ListBoxPrivate Sub ListBox_MouseMove(Button As Integer, Shift As Integer, X As Single, _    Y As Single)    Dim oldFont As StdFont, itemIndex As Long        ' since a listbox doesn't have a TextHeight method    ' we must borrow it from its Parent    With ListBox.Parent        Set oldFont = .Font        Set .Font = ListBox.Font        ' determine which element the mouse is on        itemIndex = Y  .TextHeight("A") + ListBox.TopIndex        ' restore fonts        Set .Font = oldFont    End With        ' set the tooltip to the current item's string    If itemIndex < ListBox.ListCount Then        ListBox.ToolTipText = ListBox.List(itemIndex)    Else        ListBox.ToolTipText = ""    End IfEnd Sub

See also  11 Effective Keyword Research Tools and Techniques
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist