I have an array of PANELs on a form and they are used as buttons. There is one event procedure assigned to them. So when I click on a button, I can see it's caption like this:
procedure TForm1.MenuAction0Click(Sender: TObject);
begin
TPanel(Sender).Font.Bold:= true;
ShowMessage( TPanel(Sender).Caption);
end;
I want to know the button number (as in array element number) and not the caption. How is this possible?
Thanks!
Use the
Tagproperty of the control. The Tag property is free to set to any integer that is useful to you, and it is not used by the control. So when you create each panel, set thePanel.Tagto the index in the array. Then you can get the index in the array by usingTPanel(Sender).Tag