2

I would like to know how to programatically determine that the data in a cell of the string grid is modified?

I have a string grid in a form. The data for the stringgrid is loading from the Database. If a user modifies the data, I would like to change the data in the database.

Please share the code.

Thanks

Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
user1469630
  • 191
  • 3
  • 5
  • 15
  • @Argalatyr OP might also be aware of all the strange things that a DBGrid does. I myself have used a TStringGrid instead of a TDBGrid simply because of the crazy ways the DB Grid works. For example, scrolling the mouse wheel actually changes your record, and doesn't even allow you to keep scrolling down the list. – Jerry Dodge Jun 28 '12 at 13:56

1 Answers1

7

The TStringGrid class has an event OnSetEditText which is triggered when user changes data in a cell. Use ACol and ARow in the event handler's parameters to identify which cell has been modified...

procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
  const Value: string);
begin
  //Use ACol/ARow to know what has changed, and Value to know what the new data is.

end;
RBA
  • 12,337
  • 16
  • 79
  • 126
Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327