3
votes

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 ?


Edit 12-Aug-2016 : Delphi 10.1 (Berlin) is not concerned

1
what version of Delphi you are using? i have the same issue with Delphi XE7 Update 1 and Delphi XE8.Zam
i'm using Delphi XE7 update 1. i've edited my post.Frédéric Hebrard
I have added the corresponding tag for you :)whosrdaddy
I tried a lot but I have the same issue. I suggest to have a look here: Tms FmxGridGianluca Colombo
@whosrdaddy: thanks for tagging and editingFrédéric Hebrard

1 Answers

1
votes

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 :

  • With the grid component (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)
  • In the Structure View go to : gridstyle > background > content > selection
  • In the Object Inspector, the Align property for selection is None by default : that's why highlighting won't spread over the entire row !
  • Change the value to 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