Is there any way to catch up when users changing row/col in a TStringGrid control (that is, when current cell changes)? Something just like C1.TrueDBGrid.RowColChange?
I just want to update/insert records (that is, to launch an SQL statement) when users modified/entered all info on a specific row.
There is 2 buttons below my grid: save and undo. Saving info OnSelectCell has the result to make the undo button useless. That's why I need to implement something like
You should be able to use OnSelectCell along with a variable to hold the "previous" row.
Assuming you initialize the TStringGrid with the cursor in Cells[1,1] (assuming one fixed row and one fixed column), at the same time initialize the variable (e.g. AOldRow) to the value 1.
Then process OnSelectCell at which time you have AOldRow(your variable) and ARow (from the parameter list) to examine and handle however you need to. As the last step, set AOldRow to ARow.
The code might look something like this (OnRowChange is your routine):
Code:
var
AOldRow:integer; // Static variable
procedure MyForm.MyGridSelectCell(Sender: TObject;
ACol, ARow: Integer; var CanSelect: Boolean);
begin
if AOldRow <> ARow then
OnRowChange(AOldRow,ARow);
AOldRow := ARow
end;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.