TAdvStringGrid - changing font sizes not working correctly.

Thanks for recent fixes, but I'm afraid there are still problems with TAdvStringGrid. In the example below you can see that changing font sizes does not work properly if you have done any cell alignments.

The problems seem to be independent of whether you are using low or high DPI and independent of using themes or not.

Specifically, if you try to change sizes by setting Grid.Font.Size or Grid.Fonts[c,r].Size or Grid.FontSizes the grid will only change fixed columns - not the regular columns. Strangley it seems to pick an arbitrary(?) set of fixed rows and columns and changes those even when I don't have any fixed rows and cols.

Things do seem to work if you change cell alignments, colors, & fonts via the event model (OnGetCellColor and OnGetAlignment) but I would much rather have both methods at my disposal.

Here is a super simple demo project. You can easily demonstrate the problem by using the spin edit control to change font sizes. You can also comment out the line setting Grid.Alignments to see it working OK. You can also comment in the alternative event-driven method which also seems to work.

I'd really apppreciate it if you could take a look as I really rely on this component. Many thanks!

Charlie Heaps

PS Using latest TAdvStringGrid (9.1.0.1) and Delphi 11.3 on Windows 11/VCL/64-bit build.

AdvScreenRedrawV3.zip (251.1 KB)

Sorry - one more issue to add to the list. If you DO use the event model for changing colors/alignments etc. then the OnGetCellColor event does not work on fixed rows or columns. There is no other event specifically to manipulate fixed cells so I think that is not intended behavior, but happy to be informed otherwise.

This is by design.
If you use cell properties to control the cell appearance (and you do so when setting alignments as cell property), the font is also under control of cell properties, i.e. grid.FontSizes[col,row]: integer;
Alternatively, control cell alignment via events and then you can still use the global font property.

On a default grid, I see no issue setting the fixed cell font via the OnGetCellColor event:

Test code:

procedure TForm1.AdvStringGrid1GetCellColor(Sender: TObject; ARow,
  ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
  if (arow = 0) or (acol = 0) then
  begin
    afont.Color := clRed;
    afont.Size := 16;
  end;
end;

Ok - thanks for clarification Bruno - could I make a small suggestion though? Perhaps add a note to the documentation to tell people to use EITHER the event model or Fonts/Alignments method? It was not obvious that one should not mix and max these approaches. But in the meantime, I've refactored to only use event model.

We made a note on page 65 of the doc and we'll update this doc in the next release.

Thanks!