3

I have a string grid that's linked to a FDMemTable and when I run the AutoSize procedure (that I added to its class helper) for the first time everything is perfect.

After that, when I try reopening the FDMemTable my Header goes back to the default size but the other lines stay the same.

My procedure is as follows:

procedure TStringGridHelper.AutoSizeCols;
var
  i, W, WMax: integer;
  Column : Integer;
begin
  for Column := 0 to Self.ColumnCount-1 do
  begin
    if Self.ColumnByIndex(Column).Width > 0 then
    begin
      WMax := Round(Canvas.TextWidth(Self.ColumnByIndex(Column).Header));
      for i := 0 to (Self.RowCount - 1) do begin
        W := Round(Canvas.TextWidth(Self.Cells[Column, i]));
        if W > WMax then
          WMax := W;
        if WMax > SizeMax then
        begin
          WMax := SizeMax;
          Break;
        end;
      end;
      Self.ColumnByIndex(Column).Width := WMax + 10;
    end;
  end;
end;

If I resize a column manually it goes back to normal.

I'm using XE7 and its a Multi-Device Application (FireMonkey)

2 Answers2

0

This is looks like Delphi XE7 Update 1 bug.

On Delphi XE8 your code works well. enter image description here

On Delphi XE7 Update1 it's looks weird. enter image description here

Zam
  • 2,880
  • 1
  • 18
  • 33
0

By Changing the FDMemTable's (to any field) it got back to normal.

I just called my Order Procedure.

  • this is hack :) unfortunately i wasn't able to make any "work-around" after comparing standard Delphi XE7 and XE8 library – Zam Jul 08 '15 at 22:13