?
Solved

using enter to get to the next editbox

Posted on 2003-02-21
5
Medium Priority
?
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

741 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