[Lazarus] Suppressing OnChange
bsquared
bwcode4u at gmail.com
Thu Nov 8 17:55:02 CET 2012
On 11/08/2012 07:28 AM, Timothy Groves wrote:
> I have a program which allows you to edit records. This is done using a
> dynamic array of records, with three strings in each record. I have
> been using TEdits to allow the user to edit the records. The record is
> updated during TEdit.OnChange.
>
> Unfortunately, whenever I push the data *from* a selected record *to*
> the form, TEdit.OnChange triggers, which tends to corrupt my data. I
> tried disabling the TEdit, using TEdit.Enabled := false, but the event
> still triggers.
>
> Any suggestions?
>
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
You can temporarily un-assign the event handler.
{ remove event handler from all edits }
with MyForm do
for (i := 0 to Pred(Form.ComponentCount)) do
if (Components[i] is TEdit) then
begin
theEdit := TEdit(Components[i])
theEdit.OnChange := nil;
end;
PushMyData();
{ re-assign the event handler to all edit }
with MyForm do
for (i := 0 to Pred(ComponentCount)) do
if (Components[i] is TEdit) then
begin
theEdit := TEdit(Components[i])
theEdit.OnChange := @OnChange;
end;
I apologize if this double posts. I had some problem with the first attempt.
--
Regards,
Brian
More information about the Lazarus
mailing list