How to make grid refresh on horizontal scroll


After hours, I’ve been unable to find any reference to this issue, here or elsewhere.
The problem shows with Multi-device applications (hence FMX not VCL), both for Android and Windows (I cannot know for iOS).

The Setup :
Place a grid (TGrid or TStringGrid) on a form.
Make the grid larger than the form by adding columns, ensuring that horizontal scrolling will be needed.
In the grid options, choose to draw ColLines, RowLines and AlternatingRowBackground.
RowSelect can also be True, to highlight an entire row at once.

The problem : When scrolling horizontally, the previously hidden part of the grid does not show any RowLines or Background (ColLines are well drawn), or highlight from RowSelect.
Coloring and drawing is cut regardless of column limits. When resizing the window to fit the grid (on Windows OS), colors and lines are well drawn on the previously hidden columns.

I’ve tried, both for OnDrawColumnCell and OnHScrollChange events :

StringGrid.Repaint, Self.Invalidate : no result
Application.HandleMessage, Application.ProcessMessages : slow down
the app
StringGrid.Canvas.Clear(0) : slow down and mess up the app
Change between Debug and Release versions : no result
Change Grid.Align to Client, None, Fit, Contents, Scale : no result

Please, does anyone know a way to make a grid display as expected when scrolled horizontally ?

Comments are closed.