Board index » delphi » DBCheckBox.Click() event - Setting value of checkbox makes event fire two times

DBCheckBox.Click() event - Setting value of checkbox makes event fire two times

Thank you Ken, you are a life saver, that worked great.

Marco

Quote
"Ken White" <kwh...@adpsi.com> wrote in message

news:3e2dbaf5$1@newsgroups.borland.com...
| Marco,
|
| > I am using Delphi 6.0 and the DBCheckBox.Click() event.
| >
| > I am some code that runs in the Click() event, and depending on a
| parameter,
| > I need to set the DBCheckBox value to True. If I set the value to
| true, the
| > Click() event fires two times????
| >
| > Is there a better way?
|
| The way around this is to unassign the OnClick handler while you're
| inside that handler's code:
|
| procedure TForm1.DBCheckBox1Click( Sender: TObject );
| begin
|   DBCheckBox1.OnClick := nil;
|   try
|     // your code goes here
|   finally
|     DBCheckBox1.OnClick := DBCheckBox1Click;
|   end;
| end;
|
| Ken
| ---
| Ken White
| kwh...@adpsi.com
|
| Clipper Functions for Delphi and C++ Builder
| http://www.adpsi.com
|
|
|
 

Re:DBCheckBox.Click() event - Setting value of checkbox makes event fire two times


Marco,

Quote
> I am using Delphi 6.0 and the DBCheckBox.Click() event.

> I am some code that runs in the Click() event, and depending on a
parameter,
> I need to set the DBCheckBox value to True. If I set the value to
true, the
> Click() event fires two times????

> Is there a better way?

The way around this is to unassign the OnClick handler while you're
inside that handler's code:

procedure TForm1.DBCheckBox1Click( Sender: TObject );
begin
  DBCheckBox1.OnClick := nil;
  try
    // your code goes here
  finally
    DBCheckBox1.OnClick := DBCheckBox1Click;
  end;
end;

Ken
---
Ken White
kwh...@adpsi.com

Clipper Functions for Delphi and C++ Builder
http://www.adpsi.com

Other Threads