TTMSFMXGrid: AutoSizeColumns()

Hello,

on Android the TTMSFMXGrid.AutoSizeColumns() has no effect. What is wrong?

Greetings

Axel


   // Grid vorbereiten
   sgHistorie.BeginUpdate;

   sgHistorie.Clear;
   sgHistorie.RowCount := length(PListe) +1;
   sgHistorie.Cells[0,0] := 'Status';
   sgHistorie.Cells[1,0] := 'Anlage';
   sgHistorie.Cells[2,0] := 'Personalnummer';
   sgHistorie.Cells[3,0] := 'Name-1';
   sgHistorie.Cells[4,0] := 'Name-2';

   try
     for I := 0 to length(PListe) - 1 do
         begin
         sgHistorie.Cells[0,i+1] := PListe.Status;
         sgHistorie.Cells[1,i+1] := PListe.Anlage;
         sgHistorie.Cells[2,i+1] := PListe.Personalnummer;
         sgHistorie.Cells[3,i+1] := PListe.Name_1;
         sgHistorie.Cells[4,i+1] := PListe.Name_2;
         end;
   finally

   end;
   sgHistorie.AutoSizeColumns();
   sgHistorie.EndUpdate;


Hi, 


To apply autosizing you need to use the OnApplyStyleLookup event.
Autosizing is not applied during creation because the cells are not yet initialized.

procedure TForm1.TMSFMXGrid1ApplyStyleLookup(Sender: TObject);
begin
  TMSFMXGrid1.AutoSizeColumns();
end;

Kind Regards, 
Pieter

Pieter Scheldeman2014-06-23 03:05:56

Hello Pieter,


thank you for the solution.

Regards,

Axel