TMS FMX Grid - Hide column

Hello,

In FMXGrid, how can we keep the original column width for columns remain visible after hide some other column of the grid ?

Thanks.

Hi,


You should be able to use the ColumnWidths property and set a value other than the default value. This way, the column widths will be kept after hiding columns.

Thank Pieter for your reply.


In my FMXGrid (version 2.3.2.4), it's doesn't work,

Here is a code sample to reproduce the problem, the form must have TMSFMXGrid and two buttons added :

procedure TForm1.FormCreate(Sender: TObject);
begin
   TMSFMXGrid1.ColumnWidths[0] := 20;
   TMSFMXGrid1.ColumnWidths[1] := 60;
   TMSFMXGrid1.ColumnWidths[3] := 300;
   TMSFMXGrid1.ColumnWidths[4] := 200;

   TMSFMXGrid1.Cells[1,0] := 'Col 1';
   TMSFMXGrid1.Cells[2,0] := 'Col 2';
   TMSFMXGrid1.Cells[3,0] := 'Large column';
   TMSFMXGrid1.Cells[4,0] := 'Col 4';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
    TMSFMXGrid1.HideColumn(2);
   // After hide :
   // the columns 3 take the width of column 2;
   // the columns 4 take the width of column 3;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
    TMSFMXGrid1.UnHideColumn(2);
end;

We traced & solved this issue. The next update will address this.

Thank you.