Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

How to view a subitem content when hover mouse on it? I have search and they using tooltip to view the subitem on listview mousemove but nothing show up. Some of my data too long which exceed my column width. So I want to preview the data by hovering mouse on it. Below are what I have tried but no luck.

VB
Private Sub lvinfo_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles lvinfo.MouseMove
        Dim LVHit As ListViewHitTestInfo
        Dim ToolTipText As String = ""
        Dim CurrentPosition As Integer = 0
        Dim LastBreakpoint As Integer = 0
        Dim ToolTipLengthPerLine As Integer = 40

        Try
            LVHit = lvinfo.HitTest(e.X, e.Y)
            If LVHit IsNot Nothing Then
                If LVHit.SubItem IsNot Nothing Then
                    ToolTipText = LVHit.SubItem.Text
                    While CurrentPosition + ToolTipLengthPerLine < ToolTipText.Length
                        LastBreakpoint = ToolTipText.Substring(CurrentPosition, ToolTipLengthPerLine).LastIndexOf(" ")
                        ToolTipText = ToolTipText.Insert(CurrentPosition + LastBreakpoint + 1, vbCrLf)
                        CurrentPosition += LastBreakpoint + 3
                    End While
                End If
            End If
            mytip.SetToolTip(lvinfo, ToolTipText)
        Catch ex As Exception
            strInfoMsg = "Oops! Something is wrong at mouse move." & vbCrLf & "Ex:-" & ex.Message
            MessageBox.Show(strInfoMsg, "Error Message!", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900