Adding A Tooltip To A ListView Item

  • Thread starter Thread starter Dino Buljubasic
  • Start date Start date
* Dino Buljubasic said:
Is it possible to add tooltip to a listview item?

Set the items' 'Tag' property to the tooltip text and add a ToolTip
component to the form. Then add this code:

\\\
Private m_HoveredItem As ListViewItem

Private Sub ListView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseMove
Dim lvi As ListViewItem = Me.ListView1.GetItemAt(e.X, e.Y)
If Not lvi Is m_HoveredItem Then
m_HoveredItem = lvi
If lvi Is Nothing Then
Me.ToolTip1.SetToolTip(Me.ListView1, "")
Else
Me.ToolTip1.SetToolTip(Me.ListView1, lvi.Tag)
End If
End If
End Sub
///

The code is untested, but it should basically work. If you find any
problems with the code, please let me know.
 
Back
Top