troubleshooting Question

Adding an event to a Button created at runtime

Avatar of ST3VO
ST3VOFlag for United Kingdom of Great Britain and Northern Ireland asked on
Delphi
5 Comments2 Solutions244 ViewsLast Modified:
Hi all,

I am creating a close button at runtime. Create the button works fine but I now need to add an onclick event to when this button is clicked on, so I can close PageControl Active Pages. I just cannot get it to work.

How do I do this please?

Here is the current code I'm using below:


Button := TSpeedButton.Create(PageControl1);
  Button.Parent := PageControl1;
  Button.Top := 0;
  Button.Left := PageControl1.Width - Button.Width;
  Button.Caption:=('X');
 // Button.OnClick := <-- This doesn't work
  Button.Visible := True;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros