Re: Set the CheckBox.Checked without the OnClick being called
- From: John Dough <nobody@xxxxxxxxxxxxxxx>
- Date: Thu, 07 Jun 2007 21:15:42 -0400
On Fri, 08 Jun 2007 00:30:38 +0200, Fons
<fonzzzNO@xxxxxxxxxxxxxxxxxxx> wrote:
Is there another way to set the CheckBox.Checked without the OnClick
being called than:
procedure TForm.SetCheckBox(A : boolean);
var SaveOnClick : TNotifyEvent;
begin
SaveOnClick := CheckBox.OnClick;
CheckBox.OnClick := nil;
CheckBox.Checked := A;
CheckBox.OnClick := SaveOnClick;
end;
Maybe in one instruction ? Ok: I can make one procedure for the
TCheckBox, one for the TEdit etc.
So I want the OnClick only when then user clicks.
You're over-complicating something which is very simple...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
runclickevent: boolean;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
runclickevent := false;
checkbox1.Checked := true;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if RunClickEvent = false then exit;
showmessage('This is only shown when needed...');
end;
end.
.
- Follow-Ups:
- References:
- Prev by Date: Re: ShowForm ?
- Next by Date: Re: Set the CheckBox.Checked without the OnClick being called
- Previous by thread: Set the CheckBox.Checked without the OnClick being called
- Next by thread: Re: Set the CheckBox.Checked without the OnClick being called
- Index(es):