I had the same question, but deleted it after I figured out what I was doing wrong.
I came to realize that it was only highlighted when it had the focus, so highlighting was not what I needed to do. Instead, i wrote some code that set the background color of the current row. Since there can be only 1 current row, and technically there can be more than one highlighted row, this made much more sense.
I came up with this and it works great. I call it on the
CurRowChangeRequest event.
Private Sub tblAlternateIGrid_CurRowChangeRequest(sender As Object, e As iGCurRowChangeRequestEventArgs) Handles tblAlternateIGrid.CurRowChangeRequest
IG_Highlight(sender, tblAlternateIGrid.CurRow.Index, e.RowIndex)
End Sub
Here is the routine that I made generic so that I could use it on any grid in my application:
Friend Sub IG_Highlight(ig As iGrid, OldIndex As Integer, NewIndex As Integer)
If ig.Rows.Count = 0 Then Exit Sub
For i As Integer = 0 To ig.Cols.Count - 1
ig.Rows(OldIndex).Cells(i).ForeColor = SystemColors.ControlText
ig.Rows(OldIndex).Cells(i).BackColor = Nothing
ig.Rows(NewIndex).Cells(i).ForeColor = SystemColors.HighlightText
ig.Rows(NewIndex).Cells(i).BackColor = SystemColors.Highlight
Next
End Sub
Granted, if you are doing other things with the background color of each cell, you will need to make some adjustments, but if (like me) you are using the alternating row color feature too, this is compatible with that, since this does not change the underlying row color.
Edited by user
2020-08-20T01:22:31Z
|
Reason: Not specified