Meest simpele oplossing: gebruik dit als KeyPress event voor alle TEdit's.
delphi Code:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: char);
begin
if Key = #13 then
begin
Key := #0;
SelectNext(Sender as TWinControl, True, True);
end;
end;
Alternatief 1
delphi Code:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);
begin
//needs Form1.KeyPreview := True!
if (ActiveControl is TEdit) and (Key = #13) then
begin
Key := #0;
SelectNext(ActiveControl, True, True);
end;
end;
Alternatief 2
delphi Code:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
Back: Boolean;
begin
//needs Form1.KeyPreview := True!
if (ActiveControl is TEdit) and (Key = VK_RETURN) then
begin
Key := 0;
Back := (Shift = [ssShift]);
SelectNext(ActiveControl, not Back, True);
end;
end;
Alle 3 de opties werken hier prima met Lazarus 1.1 r38083 FPC 2.6.0 i386-win32-win32/win64
Bart
Bookmarks