1.11M Members

Event handler for dynamically created panel

 
0
 

How do I specify a mouseDown eventhandler to dynaically creted Tpanels? My intention is to create a number of panels, like tiles, and move them around on the Form
I have created a design time TPanel and copied its OnMouseDown event and saved it as PanelMouseDown.
My code:

Pan:=TPanel.Create(Form2);
Pan.Height:=60;
Pan.Width:=60;
Pan.Parent:=Form2;
Pan.DragMode:=dmManual;
Pan.OnMouseDown :=Form2.PanelMouseDown;

I cant get the panels to react on mouseclicks. Does somebody have any suggestions?

 
0
 

That code looks okay. What's in the event handler? What happens when you step through it with the debugger?

 
0
 

Event handler never get trigged. Code for the moment is only beep;

 
0
 

Show the event handler.

Question Answered as of 1 Year Ago by pritaeas
 
1
 

Sorry bothering you all! I had put a label over the panel and the label covered the whole Panel so the Label was clicked instead of the Panel. Increasing the panel and clicking outside the label all worked well and the cration cod for the panel was correct. Thanks pritaeas for your engagement. Case closed.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: