Tooltip on a listview Item

I am loading a list view with reports ,I want to display a tooltip as the mouse pointer hovers over an listitem ,can this be done and how?
Cheers T
Who is Participating?
grayeConnect With a Mentor Commented:
As you've probably figured out... there is no "hover event" for the ListViewItems objects.   So, you have to make one "by hand".

In this example below, the tooltip data comes from a dataTable... but other than that one oddity, it's pretty straight forward.

    Private Sub ListView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseMove
        Dim lvi As ListViewItem
        Dim drs() As DataRow
        Static last_lvi As Integer = -1

        ' this is a poor man's "ListItem_MouseHover event"
        lvi = ListView1.GetItemAt(e.X, e.Y)
        If Not IsNothing(lvi) Then
            If lvi.Index <> last_lvi Then
                drs = dt.Select("PC_Name='" & lvi.Text & "'")
                If UBound(drs) >= 0 AndAlso drs(0)("ID") <> "" Then
                    ToolTip1.SetToolTip(Me.ListView1, "Comment: " & drs(0)("PC_Comment") & vbCr & "User: " & drs(0)("UserName") & vbCr & "Model: " & drs(0)("PC_Model") & vbCr & "OS: " & drs(0)("OS") & vbCr & "Bldg: " & drs(0)("Bldg") & vbCr & "Div: " & drs(0)("Division"))
                    ToolTip1.SetToolTip(Me.ListView1, "No Data")
                End If
            End If
            last_lvi = lvi.Index
            ToolTip1.SetToolTip(Me.ListView1, "")
            last_lvi = -1
        End If

    End Sub
Unfortunately, list items are not controls and there is no supplied hit test, so if you want, you can use the following solution.
I believe the list item height must be fixed to use this:

The datagrid does supply a hittest for tooltips.
See this link for instructions:
Hummm... I realized that my example lacked a great deal of explaination!

I set a tooltip control to active on the entire ListView object... then programmatically change the contents of the tooltip's data to be displayed based upon which ever ListViewItem is currently selected.   So the example above does that... it detects which ListViewItem is current and (in my somewhat strange example) queries a database to populate the contents of the ToolTip.
All Courses

From novice to tech pro — start learning today.