Persist DataGrid properties

I use this code to load settings in FormShow:

if FileExists('.\gridInvoice') then
gridInvoice.LoadSettingsFromFile('.\gridInvoice');

FormClose;

gridInvoice.SaveSettingsToFile('.\gridInvoice');

When showing the form, the error appears like in attach.

Thanks for helping Adrian

We tested this here quickly with a default grid and some sample data, and could succesfully save & load to JSON. Please provide some more details, or a test case

adapterInvoice.Enabled:= false;
    adapterInvoicePosition.Enabled:= false;

    with tableInvoice do
    begin
        Close;
        Open;
    end;

    with tableInvoicePosition do
    begin
        Close;
        Open;
    end;

    if FileExists('.\gridInvoice') then
        gridInvoice.LoadSettingsFromFile('.\gridInvoice');

    indSent := adapterInvoice.ColumnAtField['FERTIG'].GridColumn.Index;
    indCanceled := adapterInvoice.ColumnAtField['STORNIERT'].GridColumn.Index;

    gridInvoice.BeginUpdate;

    for i := 0 to gridInvoice.RowCount - 1 do
    begin
        gridInvoice.AddCheckBox(indSent, i, false);
        gridInvoice.AddCheckBox(indCanceled, i, false);
    end;

    gridInvoice.EndUpdate;

    gridInvoice.Sort(1, TTMSFNCDataGridSortDirection.gsdAscending);

    bAdvFilter.Enabled:= false;
    gridInvoice.Options.Filtering.Advanced:= false;

    adapterInvoice.Enabled:= true;
    adapterInvoicePosition.Enabled:= true;

This is the code i setted in FormShow

The grid is grouped, i would like save and load only the column sizes and the visual grouping.

We have tested this on our multi-column grouping demo and this works as expected. It’s unclear exactly what is triggering the access violation. Can you put together a test sample?