Hi,
I have a livegrid binded to a tfdquery. This grid has 3 columns: a, b and c. c=a+b needs to be always kept . Now what I am trying to do is: when a user change values of a or b, the c should be changed too as c=a+b. Also the binded table should be updated through the binding. It sounds easy, but I am sure I must hit some stone and I just couldn't get over. Does any one have solution or sample codes for it? Thanks in advance!
Gene.
Hi,
Values updating is done per cell. You could change the field directly which will then update the value in the grid.
procedure TForm1.TMSFMXGrid1CellEditSetData(Sender: TObject; ACol,
ARow: Integer; CellEditor: TFmxObject; var CellString: string);
begin
if CellString = 'a' then
begin
BindSourceDB1.DataSet.DisableControls;
BindSourceDB1.DataSet.Edit;
BindSourceDB1.DataSet.Fields[ACol].AsString := 'test';
BindSourceDB1.DataSet.Post;
BindSourceDB1.DataSet.EnableControls;
end;
end;
Kind Regards,
Pieter
It works! thanks!