Question Show Tooltip On ListView Item

sonia.sardana

Active member
Joined
Jan 25, 2009
Messages
35
Programming Experience
Beginner
I have added three images to ImageList..I want to show tooltip....On listview item...

VB.NET:
Public Class Form2

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListView1.View = View.LargeIcon
        ListView1.LargeImageList = ImageList1
        For lcount As Integer = 1 To 3
            ListView1.Items.Add(lcount.ToString, lcount - 1)
        Next

    End Sub

    Private Sub ListView1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.MouseLeave
        Dim a As New ToolTip
        a.SetToolTip(ListView1, "")
    End Sub

    Private Sub ListView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseMove
        Dim thisItem As ListViewItem = ListView1.GetItemAt(e.X, e.Y)

        Dim a As New ToolTip

        If Not thisItem Is Nothing Then

            a.SetToolTip(ListView1, thisItem.Text)

        Else

            a.SetToolTip(ListView1, "")

        End If

    End Sub
End Class

Mine code is working fine..But probs is that..as i hover the mouse suppose over the first image tooltip is shown..Now when i hover the mouse on second image..first image tooltip is still there..I want first tooltip to be disappeared...How to do that..can somebody tell me help me??/
 
Add a Tooltip component to your form and Show/Hide this, don't create a new new tooltip in MouseMove event.

You can also do this simpler with the ItemMouseHover event, which will display the tooltip like they usually do, ie when mouse hovers.
VB.NET:
Private Sub ListView1_ItemMouseHover(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemMouseHoverEventArgs) Handles ListView1.ItemMouseHover
    Me.ToolTip1.Show(e.Item.Text, CType(sender, IWin32Window))
End Sub
 
Sir sorry to say dat but no tooltip is shown,When i hovers the mouse over the item....But thx for the rely..I find the other way to do it-

VB.NET:
Dim lvPlayer As ListViewItem
  lvPlayer = LvwPlayer.Items.Add(IO.Path.GetFileNameWithoutExtension(sFileName), ImgPlayer.Images.Count - 1)
                    lvPlayer.ToolTipText = IO.Path.GetFileNameWithoutExtension(sFileName)
                    lvPlayer.Tag = sFileName


Can u plz tell me it it possible to show image in tooltip!!!!!!!
 
an u plz tell me it it possible to show image in tooltip
Check out the OwnerDraw Property in help, there's a code sample there too.
 
Back
Top