We help IT Professionals succeed at work.

datagridview hidden cell inside tool tip

When I hover over a cell can it display information from a hidden cell inside of the datagridview?
Comment
Watch Question

Top Expert 2016
Commented:
yes, if you provide the text for the tooltip dynamically you could show any text you like. see the following sample code

Private cellColumnIndex As Integer = -1, cellRowIndex As Integer = -1
Private Sub testDataGridView_CellMouseMove(ByVal sender As Object, ByVal e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseMove
    If e.ColumnIndex <> Me.cellColumnIndex OrElse e.RowIndex <> Me.cellRowIndex Then
        Me.ToolTip2.Hide(Me.DataGridView1)
        Me.cellColumnIndex = e.ColumnIndex
        Me.cellRowIndex = e.RowIndex
        If Me.cellColumnIndex >= 0 AndAlso Me.cellRowIndex >= 0 Then
            Me.ToolTip2.SetToolTip(Me.DataGridView1, ConnectedUsers(Me.DataGridView1.Rows(e.RowIndex).Cells("Database").Value, Instance))
        End If
    End If
End Sub

Open in new window


here the SetToolTip could be used to determine which text to display.

Sara
Top Expert 2016

Commented:
There was no response to the given solution but it might have helped nevertheless and could help others who have the same issue.

Sara