Zobrazení tooltipu u listitems i subitems (pomocí ListViewHitTestInfo) Form1 s vloženým prvkem ListView1 : (view=details, sloupce viz. link výše)
Public Class Form1
Inherits System.Windows.Forms.Form
Private tt As ToolTip
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
tt.Dispose()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tt = New ToolTip()
End Sub
Private Sub ListView1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.MouseLeave
If tt.Active Then tt.Hide(Me.ListView1)
End Sub
Private Sub ListView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseMove
Dim lvhti As ListViewHitTestInfo
lvhti = ListView1.HitTest(e.X, e.Y)
If Not lvhti Is Nothing Then
Dim s As String = ""
If Not lvhti.SubItem Is Nothing Then
s = lvhti.SubItem.Text
If tt.GetToolTip(Me.ListView1) <> s Then
tt.Show(s, Me.ListView1, lvhti.SubItem.Bounds.Left, lvhti.SubItem.Bounds.Top)
End If
Else
If tt.Active Then tt.Hide(Me.ListView1)
End If
Else
If tt.Active Then tt.Hide(Me.ListView1)
End If
End Sub
End Class
Jak by šlo zobrazit tooltip pouze pro případy, kdy není vidět celý text? Jak zjistit, zda je u item nebo subitem zobrazen celý text nebo jen částečně následovaný... ?
|