Page 1 of 1

Problem with ediing data in grid

Posted: Mon Jan 22, 2018 2:13 pm
by 18681439
I have 2 grids on form.
1 - Main data.
2 - Slave data. Data changes all time when I change maindata row.

If I edit data in slave grid and after editing make click in same (slave) grid -- all is fine.
Only if after editing I make click on maindata grid, I get:
at first: FastMM error: error during GetMem operation. Block has been modified being freed
at second: system error: Out of memory.

Re: Problem with ediing data in grid

Posted: Wed Jan 24, 2018 10:40 am
by 18681439
Problem resolved (partly) by adding the following code:

Code: Select all

procedure TMainForm.tgrdAttributesCellEdited(const Sender: TObject;
  const AEditor: TControl; const AColumn: TColumn; const ARow: Integer;
  var ChangeData: Boolean; var NewData: string);
begin
  if MainForm.Focused.GetObject <> tgrdAttributes then
    ChangeData:= False;
end;
onCellEdited not fired before onExit event.

It's still a problem. In this example, the data entered by the user is destroyed. How to store them?

Re: Problem with ediing data in grid

Posted: Wed Jan 24, 2018 11:10 am
by 18681439
NB. I use FMX.

Re: Problem with ediing data in grid

Posted: Thu Jan 25, 2018 7:57 am
by yeray
Hello,

Could you please arrange a simple example so we can reproduce the problem here?
Thanks in advance.

Re: Problem with ediing data in grid

Posted: Thu Jan 25, 2018 2:39 pm
by 18681439
Exact error duplication:
A) Select the first line of mastergrid (Left grid).
b) Edit slave cell (right grid).
c) Left the changed cell with the mouse and click on the mastergrid last line.

A slightly different error occurs when after edit click mastergrid second or third line.

Demo location: https://www.online.ee/sharefile.php?sha ... 8249e07f9f

Re: Problem with ediing data in grid

Posted: Fri Jan 26, 2018 10:25 am
by yeray
Hello,

You are copying your original data to MainSlaveData everytime you select a new row in the main grid. This is overriding the changes in MainSlaveData.
Instead, you could use an array to access your slave data. Ie:
Demo to Steema.zip
(48.78 KiB) Downloaded 1513 times