Board index » delphi » OnChange handler for dynamically created controls?

OnChange handler for dynamically created controls?

Hi all!

I'm adding some Controls (TCheckBox, TButton, ...) to a TPageControl
like this:

  with TCheckBox.Create(self) do begin
    Parent := PageControl1.Pages[idx];
    Caption := 'a cation'
    Top := 4;
    Left := 4;
  end;

Now ''d like to implement an event handler for this dynamically created
control.
How can i link my own OnChange-function to this control?

Thanks in advance,
Olaf Schroeder.

 

Re:OnChange handler for dynamically created controls?


Quote
>Now ''d like to implement an event handler for this dynamically created
>control.
>How can i link my own OnChange-function to this control?

You first have to write the event handler as a method that has the
proper parameters, i.e.:

TForm1.MyOnChange(Sender : tObject);
begin
  // Do something
end;

You then assign the handler just like any other property:

 OnChange := MyOnChange;

-Mike

Re:OnChange handler for dynamically created controls?


On Mon, 17 Aug 1998 21:24:06 +0200, "Olaf Schr?der"

Quote
<o...@student.uni-siegen.de> wrote:
>How can i link my own OnChange-function to this control?

You create an event handler method, just as if you let Delphi write
the code for you. You then assign the method to the event:

MyCheckBox.OnChange := MyCheckBoxChange;

---
Yorai Aminov (TeamB)
http://ourworld.compuserve.com/homepages/yaminov
(TeamB cannot answer questions received via email.
To contact me for any other reason remove nospam from my address)

Other Threads