Delphi .NET (2) Database (71) Delphi IDE (90) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Change text in a OnChange event without stack overflow
This article has not been rated yet. After reading, feel free to leave comments and rate it.
If you change a TEdit text in its OnChange event, e.g. to do some adjustments, it will fire the event recursively until stack exhausts.
You can temporarily disable the event handler just by setting the internal method pointer to nil.
Don't forget to set it back to the right procedure - this sample shows how to do it:
 | |  | |
procedure Form1.Edit1Change(Sender : TObject);
begin
Edit1.OnChange := NIL;
if Edit1.Text = 'Some Text' then
Edit1.Text := 'New Text';
Edit1.OnChange := Edit1Change;
end;
| |  | |  |
Comments:
|