Mega Code Archive

 
Categories / Delphi / Examples
 

How to jump on enter to the next control

Title: How to jump on enter to the next control Question: In many cases the input of data has to be fast. Therefore many users want to have the cursor at the next control automatically when they press enter. Answer: This solution uses the OnKeyPress event from the form and the vcl message call 'perfrom'. type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; procedure FormKeyPress(Sender: TObject; var Key: Char); private public end; var Form1: TForm1; procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then Self.Perform(WM_NEXTDLGCTL, 0, 0); end;