FMXGrid Column Width Problem


Hopefully this will be my last question. I have a problem with the column width changing between different shows and activations of the form. On the first show the column widths are set fine but thereafter they revert to default column widths.

I am doing this on formshow :

  gdOrderLinesTMS.ColumnWidths[0] := 80;
  gdOrderLinesTMS.ColumnWidths[1] := 250;
  gdOrderLinesTMS.ColumnWidths[2] := 80;
  gdOrderLinesTMS.ColumnWidths[3] := 120;
  gdOrderLinesTMS.ColumnWidths[5] := 80;
  gdOrderLinesTMS.ColumnWidths[5] := 120;
  gdOrderLinesTMS.ColumnWidths[6] := 120;
  gdOrderLinesTMS.ColumnWidths[7] := 120;

Then on reopening the form it looks like this :

Is there event that I should rather set the column widths ? I have tried doing it on paint.


I could not reproduce an issue. You refer to: "when I reopen the form"... what exactly does this technically mean? Is this a hidden form you open again or you recreate the form instance and display it?

When the form is reopened, is it going again through the FormShow event?


No, sorry I am not hiding it and then reshowing, in this case I am clicking the + button to add an item. This does a showmodal of another form like this :

  if datamod.mtOrderHeaderDEBTOR_ID.AsString = '' then begin
    messagedlg('Please select a customer',System.UITypes.TMsgDlgType.mtError ,[TMsgDlgBtn.mbOK],0);
   Stock.editing := false;
   Stock.enquiry := false;

   Stock.ShowModal(procedure(ModalResult: TModalResult)
      if ModalResult = mrOK then
      // if OK was pressed and an item is selected, pick it


Once that form is closed it sets focus back to this form.

However, I have also experienced this by showing the form, closing it and the opening it. This form is opened like this ;

  orderdetails.ShowModal(procedure(ModalResult: TModalResult)
                 { if ModalResult = mrOK then
                  // if OK was pressed and an item is selected, pick it

Sorry just to add to this, the Columnsize options on the grid are set like so :


It's unclear what is causing this. Can you try to isolate this in a sample source app and send this by email so we can investigate?

Hi Bruno

I have managed to overcome this issue by executing 


after I set the column widths. Perhaps a bug with Delphi XE7 ?


Thank you for your feedback, we will further investigate this here, but it could be possible that this is a XE7 specific issue.

Kind Regards, 

I also have the same problem, I set the column width , but when I run it they all back to defaults , using Delphi XE8

How exactly to reproduce?
When dropping a default TTMSFMXGrid on the form and setting the column width via design time editor for grid.Columns[x].Width: integer, this width is reflected when running the app.
What are you doing different?

Hi I set the with in the object inspector for every column, but they change when I run the app in windows

I cannot see such problem here. Is there any alignment or anchoring being done with this grid?

I removed anchoring and no change, Grip is align to top, I have 4 columns the first 2 is small (60)and the next 2 need to be biggeg (200) . even set defaultcolumnsize to 0 , but all the columns are the same size

I cannot reproduce this with the latest version of TTMSFMXGrid. The column widths as configured at design time always appear when the app is started.
If a problem persists with the latest version, please provide some sample source app with which we can reproduce the problem here.

Ich habe ein Problem mit TMXFMXGrid. Die Daten lassen sich im Grid editieren, werden aber nicht auf die Datenbank zurückgeschrieben. Ich arbeite mit Delphi XE8 

Is this a grid with livebindings? If so, we recommend to use TTMSFMXLiveGrid.

Thank you, but it does no longer work this code

procedure TLoginFrm.TMSFMXLiveGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var Allow: Boolean);
  if ACol = 3 then
    TMSFMXLiveGrid1.Cells[ACol,ARow] := MD5(TMSFMXLiveGrid1.Cells[2,ARow]);


To write to the grid, you need to directly write to the database instead of writing to the grid cells. The grid cells are automatically filled with data, and the editing occurs internally. In the SelectCell event the dataset is not set in edit mode.

Kind Regards, 

I have a problem with the TMSFMXLifeGrid. The database pointer is not equal to the pointer of TMSFMXLifeGrid.Wenn on the grid, the second record is CHANGED, in the table of the first data set is overwritten. You have a solution?

Please note that the ARow parameter is 1 for the first record if fixedrows are used and thus needs to be subtracted by 1.
Pieter Scheldeman2015-08-12 15:50:25

You have misunderstood. When I press on the grid to col 2 and the data mutate, the data from the first record in the table is mutated. Table and Grid do not have the same record.