PDA

View Full Version : Trapping DBGrid Movement Between Columns


AlMack
07-26-2001, 06:47 PM
I have a dbgrid attached to a table. There are 5 fields on the grid. When I insert a new record in the grid, and input the number '370' into the first field, I want to trap the event moving into the next column, so I can automatically insert 2 values into 2 of the other columns.

How can I achieve this?

Thanks!

LörAn
07-26-2001, 09:28 PM
Maybe you can try using your DBGrid's OnColExit() (or OnColEnter()) event :

procedure DBGrid1ColExit(Sender: TObject);
begin
if ((Sender as TDBGrid).DataSource.DataSet.FieldByName('Field1'). asString = '370') then begin
((Sender as TDBGrid).DataSource.DataSet.FieldByName('Field2'). asString := 'Val2';
[...]
end;
end;


LörAn.
ICQ #112714184

LörAn
07-26-2001, 11:53 PM
Just a precision :
maybe you'll have to call the (Sender as TDBGrid).DataSource.DataSet.Edit() procedure before changing the other columns values.
But I think you have already noticed that...
;)

LörAn.
ICQ #112714184