How to update the grid in horizontal scrolling

After hours, I have not been able to find a link to this problem here or elsewhere. The problem manifests itself in multi-device apps (hence FMX not VCL), for both Android and Windows (I can't know for iOS).

Customization: Place the grid ( TGrid

or TStringGrid

) on the shape. Make the grid larger than the shape by adding columns to provide horizontal scrolling. In the grid options, select drawing ColLines

, RowLines

and AlternatingRowBackground

. RowSelect

can also be True to highlight the whole line at once.

Problem: When scrolling horizontally, the previously hidden portion of the grid does not show any RowLines

or background ( ColLines

well drawn) or stands out from RowSelect

. Coloring and painting are cut regardless of column limits. When the window is resized to fit the grid (on Windows), colors and lines are drawn well on previously hidden columns.

I've tried, for OnDrawColumnCell

both OnHScrollChange

events and events:

  • StringGrid.Repaint, Self.Invalidate

    : no result
  • Application.HandleMessage, Application.ProcessMessages

    : slow down the application
  • StringGrid.Canvas.Clear(0)

    : slow down and mess up the application.
  • 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 the grid display as expected when scrolling horizontally?


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

+3


source to share


1 answer


Ok I found it. Finally.

In order for the highlight to spread over the entire line when it is selected (even the hidden part), you need to play with Styles .

I didn't go into style editing, but here's what to watch:



  • With a grid component ( TGrid

    , TStringGrid

    ) in the form, right-click the grid and select Change Default Style or Change Custom Style to open the FireMonkey Style Designer (see DocWiki for details )
  • In Structured View, follow the link:gridstyle > background > content > selection

  • In the Object Inspector, the property Align

    for selection

    by default is None

    : why won't highlighting spread across the entire line!
  • Change the value to Horizontal

    and you're done. Other values ​​won't do the trick. ( Contents

    , Client

    : entire mesh selected) ( Fit

    , Center

    : selection focused on mesh)

Surprisingly, in Delphi 10.1, the default configuration is the same, but choosing the correct spread across the entire line when needed ...

Note: gridstyle

- TLayout

; background

- TRectangle

; content

- TLayout

;selection

TRectangle

+1


source







All Articles