Use ENTER in a TEdit box!

Posted on 2006-03-20
Last Modified: 2010-04-05
How to make the ENTER an event in a TEdit box?
I have now used the Button1Click in a button, but it si a bit bothersome.
Question by:liljen_80
    LVL 15

    Accepted Solution

    Use the OnKeyPress event of the edit box to do something when the ENTER key is pressed.
    Is this what you mean?

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
      if Key = #13 then
        // DO SOMETHING
    LVL 13

    Expert Comment

    in addition to that...

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
      if Key = #13 then
        Key:=#0; //"eat" the key, so it doesn't beep
        // DO SOMETHING

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now