I.T. Discussion Community!
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

October Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingDelphi for W...Using Controls   Print This     
Part of the mo. lesson in the Oct 15 Issue of Prestwood eMag
Delphi Q&A Flashcard:
 A flashcard from our Delphi Flashcards Library
 A FAQ from our Delphi FAQ Page
TEdit OnChange events

Question:

I have a form with two TEdit components on it. For the OnChange event for both, it clears the contents of the TEdit that is not changing. However, when clearing on TEdit the OnChange fires and clears the other TEdit, this then causes the OnChange in the other TEdit to fire. Fortunately, the second time the OnChange hits the original TEdit, it is already clear and nothing happens. How can I prevent the circular event firing?

Answer:

The simplest way to prevent the circular event firing is to check the form's ActiveControl property. This property indicates which component currently has the focus.

The OnChange event should read as follows:

procedure TForm1.EditChange(Sender: TObject);
begin
if TEdit(Sender).Name <> TEdit(ActiveControl).Name then
   begin
       // do processing
   end;
end;

Comments

1 Comments.
Share a thought or comment...
Comment 1 of 1

Question need all answers. If you have the answers of all of these questions then you have to come and tell me some more which is just do more at the time when we are write my assignment for me so must leave answers of these questions.

Posted 5 months ago
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1262A1
Enter key:
FAQ Contributed By Larry J. Rutledge :
I worked for Prestwood Software as a Delphi developer from 1997 through 2002. During that time I enjoyed working with Mike Prestwood and the other developers at Prestwood.
Visit Profile

 KB Article #101671 Counter
14755
Since 12/9/2008

Follow PrestwoodBoards on: 


©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech