Re: Adding A Tooltip To A ListView Item

From: Herfried K. Wagner [MVP] (hirf-spam-me-here_at_gmx.at)
Date: 06/09/04


Date: 10 Jun 2004 00:08:51 +0200


* Dino Buljubasic <dino@noplacelikehome.com> scripsit:
> 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.

-- 
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


Relevant Pages

  • Tooltips bei einer ListView (TreeView oder ListBox)
    ... man über das zweite ListViewItem geht, ... Nun hab ich den Code geschrieben, der beim bewegen der Maus, feststellt, ... Ergebniss) um dort den Tooltip anzeigen zu lassen. ... ItemListViewItem lvi = sender as ItemListViewItem; ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: displaying many lines in ListView
    ... Tooltip would be quite a good idea if it weren't for the fact that I 'd ... have to associate with ListViewItem, rather than control. ... Piotrek ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ListView images will not show!
    ... Make sure to add Column headers using the Columns property. ... Dim lvi = New ListViewItem() ...
    (microsoft.public.dotnet.languages.vb)
  • Re: ListBox works - Is this correct?
    ... ListViewItem.ImageIndex property to whatever icon you want: ... For Each lvItem As ListViewItem In lv.CheckedItems ... Dim lvi As ListViewItem ...
    (microsoft.public.dotnet.languages.vb.controls)
  • ListBox works - Is this correct?
    ... Dim lvi As ListViewItem ... On a button click to replace the icon. ...
    (microsoft.public.dotnet.languages.vb.controls)