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 resultApplication.HandleMessage, Application.ProcessMessages
: slow down
the appStringGrid.Canvas.Clear(0)
: slow down and mess up the appGrid.Align
to Client, None, Fit, Contents, Scale : no resultPlease, does anyone know a way to make a grid display as expected when scrolled horizontally ?
Edit 12-Aug-2016 : Delphi 10.1 (Berlin) is not concerned
Ok I found it. At last.
For the highlighting to spread over the entire row when selecting it (even the hidden part), one have to play with Styles.
I didn't go deep inside style editing but here's what to look at :
TGrid
, TStringGrid
) on a form, right-click the grid and choose Edit Default Style or Edit Custom Style to open a FireMonkey Style Designer window (see DocWiki for details)gridstyle > background > content > selection
Align
property for selection
is None
by default : that's why highlighting won't spread over the entire row !Horizontal
and you're done. Other values will not do the trick. (Contents
, Client
: the entire grid is highlighted) (Fit
, Center
: highlighting is centered on the grid)Surprisingly, in Delphi 10.1, default configuration is the same but selection correctly spread over the entire row if needed...
Note : gridstyle
is TLayout
; background
is TRectangle
; content
is TLayout
; selection
is TRectangle