unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Grids, DBGrids;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Table1: TTable;
procedure DBGrid1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then begin
if HiWord(GetKeyState(VK_Shift)) <> 0 then begin
with (Sender as TDBGrid) do
if SelectedIndex > 0 then
SelectedIndex := SelectedIndex -1
else begin
Datasource1.DataSet.Prior;
SelectedIndex := fieldcount -1;
end;
end else begin
with (sender as TDBGrid) do
if SelectedIndex < (fieldcount -1) then
SelectedIndex := SelectedIndex + 1
else begin
datasource1.DataSet.Next;
SelectedIndex := 0;
end;
key := #0
end;
end;
end;
end.