Private Sub ListBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseMove
Dim MousePositionInClientCoords As Point = New Point(e.X, e.Y)
Dim indexUnderTheMouse As Integer = Me.ListBox1.IndexFromPoint(MousePositionInClientCoords)
If indexUnderTheMouse > -1 Then
Dim s As String = Me.ListBox1.Items(indexUnderTheMouse).ToString
Dim g As Graphics = Me.ListBox1.CreateGraphics
If g.MeasureString(s, Me.ListBox1.Font).Width > Me.ListBox1.ClientRectangle.Width Then
Me.ToolTip1.SetToolTip(Me.ListBox1, s)
Else
Me.ToolTip1.SetToolTip(Me.ListBox1, "")
End If
g.Dispose()
End If
End Sub