Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

using enter to get to the next editbox

Posted on 2003-02-21
5
Medium Priority
?
230 Views
Last Modified: 2010-04-04
Hie can someone help me so that I  use the  Enter key  to go to the next  editbox  my email is
 terrychims@yahoo.com please help I wanna use this  on my project
0
Comment
Question by:Chimusoro
5 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7996276
Hello

  First check the enter key is pressed then use SelectNext to move to next control on your form

and to make this work for all controls on your form, place the code in KeyPress event of your form, but you need to change the KeyPreview property of your form to True

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
    SelectNext(ActiveControl,True, True);
end;

Best regards
Mohammed Nasman
0
 
LVL 2

Accepted Solution

by:
ferhad earned 200 total points
ID: 7996358
Insert 2 Edit boxes into your project and in KeyPress event of the first type the following code :

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then Edit2.SetFocus
end;

Hope it will help you.I have tested it
Regards Ferhad
0
 

Expert Comment

by:luisseixas
ID: 7997613
     The thing is: How do you avoid the BEEP sound when pressing "Enter" on a TEdit?
      Once I solved this problem substituing my TEdits for TMemos, making it the same size and turning the "WantReturns" property OFF.
      Combinding it with "ferhad's" comment up here, it should work very well.
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7997718
Hello

  what's about if you have 10 EditBoxes, than you will need to write the code 10 times, and that not efficient, so writing the code in form is better, but don't forget to change the KeyPreview property of the form

also if you want to avoid the BEEP, simply just add Key := #0

my code will be like

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    SelectNext(ActiveControl,True, True);
    Key := #0;
  end
end;

Best regards
Mohammed Nasman
0
 

Author Comment

by:Chimusoro
ID: 8004460
thanks a lot
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question