AutoSizeRows on TAdvStringGrid not taking scaling in account?

I am using the TAdvStringGrid and just upgraded from the old GridPack to the latest VCL UI Pack.
I am observing, that AutoSizeRow is no longer accurately sizing the row heights when there is scaling applied to the form. (e.g. manually by ScaleBy(5,2); )

In a fresh test project, I compared the result old vs new:


Current UI Pack, with extra space on each row:

Is there something I can do or is it an issue with the AutoSizeRows/Columns ??

OS: Windows 11
IDE: C++Builder Tokyo 10.2.3

Testproject: (129.0 KB)


What is the DPI of the screen you are running this on?

I was running it on default 96 dpi.

But I can also see the same behaviour when not manually scaling but moving the app to a monitor with 200% scaling (scaling set in the windows screen configuration).

Only when there is no scaling at all, the row looks fine.

I have retested with a default grid on the form initialized with:

procedure TForm1.FormCreate(Sender: TObject);
  advstringgrid1.DefaultRowHeight := 48;

procedure TForm1.Button1Click(Sender: TObject);

I perform this on a 100% DPI screeen, 200% DPI screen: no issue can be seen

I perform this when starting the app on the 200% DPI screen, move it to the 100% DPI screen and perform AutoSizeRows() and vice versa : no issue can be seen

I move the app before and after resizing from 100% to 200% screen and vice versa : no issue can be seen

I tested this both with Delphi 10.2 and Delphi 12.

Hmm, also with your table data code, and a fresh placed grid I still have the issue.
The same when using C++Builder 12.

To be precise: the row is shrinked when calling AutoSizeRows, but the padding on the bottom of each row is still about double the padding on the top of the row.
This makes the table listings considerably larger than necessary.

Can there be a difference between C++ and Delphi test projects?
Could you share your test-project with the binary?


I extended the test with showing the calculated row height

procedure TForm1.Button1Click(Sender: TObject);
  caption := advstringgrid1.RowHeights[1].ToString;

in 100% DPI, the result here is 22
in 150% DPI, the result here is 33
in 200% DPI, the result here is 44

this looks the expected result to me.

The numbers may look nice, but the visual layout doesn't. The Row is not shrunk to the Text height.

Currently, I get the expected result, when calculating and setting the row heights manually (under certain assumpsions)

grid1->RowHeights[iRow] = grid1->Canvas->TextHeight("gh");

But that shouldn't be necessary.

Row sizing by AutoSizeRow:

Row sizing by TextHeight