• Rob
  • Newbie Topic Starter
I'm using Access 2007 and the latest version of the ActiveX control. Is there a way to change the background color of the sorted column(s)? For instance, if col 1 is sorted it background color would change to indicate it was sorted. It column 2 was then select, column 1 would change back to the default color and then column 2's background color would change. I'm assuming I would need to program this in. It looks like I should be using the ColHeaderClick event set this. Am I on the right track? Does anyone have any sample code?

-- Rob
If you were going to update the cell backcolors in the clicked column in the ColHeaderClick event, this can be very slow in grids with 1000+ rows. There is a better way - cell dynamic formatting. It is performed only for the cell sin the view port. In fact, all work can be done in the corresponding CellDynamicFormatting event:

Private Sub iGrid0_CellDynamicFormatting(ByVal lRow As Long, ByVal lCol As Long, ByVal vValue As Variant, oForeColor As Long, oBackColor As Long, oFont As Object)
    If iGrid0.ColSortKey(lCol) > 0 Then
        oBackColor = RGB(255, 240, 255)
    End If
End Sub

(ColSortKey returns a positive value if a column is sorted).

But we need ColHeaderClick though - to update the grid according to the changed sort criteria:

Private Sub iGrid0_ColHeaderClick(ByVal lCol As Long, bDoDefault As Boolean, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
End Sub