I've got a ToolTip showing when hovering over a row in my DataGridView - Works great except for the ToolTip flickering when over a row that displays it.
Private Sub DataGridView1_MouseHover(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseMove
Dim hit As DataGridView.HitTestInfo = DataGridView1.HitTest(e.X, e.Y)
If hit.Type = DataGridViewHitTestType.Cell Then
If Not hit Is m_HoveredItem Then
Me.ToolTip2.Hide(Me.DataGridView1)
m_HoveredItem = hit
If hit Is Nothing Then
Me.ToolTip2.SetToolTip(Me.DataGridView1, "")
Else
'Me.ToolTip2.SetToolTip(Me.DataGridView1, ConnectedUsers(Me.DataGridView1.Rows(hit.RowIndex).Cells("Database").Value, Instance))
Me.ToolTip2.Show(ConnectedUsers(Me.DataGridView1.Rows(hit.RowIndex).Cells("Database").Value, Instance), DataGridView1, e.X, e.Y)
End If
End If
End If
End Sub
I used a similar method for a ListView which worked great:
Private m_HoveredItem As ListViewItem
Private Sub lv_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim lvi As ListViewItem = Me.LVDatabases.GetItemAt(e.X, e.Y)
If Not lvi Is m_HoveredItem Then
Me.ToolTip2.Hide(Me.LVDatabases)
m_HoveredItem = lvi
If lvi Is Nothing Then
Me.ToolTip2.SetToolTip(Me.LVDatabases, "")
Else
Me.ToolTip2.SetToolTip(Me.LVDatabases, ConnectedUsers(Me.LVDatabases.GetItemAt(e.X, e.Y).Text, Instance))
End If
End If
End Sub