Onclick event for a checkbox create at runtime

calebS
calebS used Ask the Experts™
on
Is there a way to create a runtime event for an object created a runtime?
I am creating checkboxes at runtime, when check I want it to go gray (or
ungray) itself and the label beside it (both in the same node in a queue),
then run a function for me.

Possible?
I am sure it is, but don't know how.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
sorry I meant to say:
Is there a way to create an OnClick event for an object created a runtime?
Top Expert 2004
Commented:
yep, possible

define your event in your code

procedure TForm1.aEvent(sender : TObject);
begin
  //do what you need
end;

in your checkbox creation do

wíth TCheckBox.Create(self) do
begin
  parent := self;
  left := ..
  top := ..
  OnClick := aEvent;
end;

meikl ;-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial