Access TSpeedButtons in a TGroupBox (Views: 14)
I need to put a lot of TSpeedButtons into a GroupBox (for example 20). For each button I set a GroupIndex. Is it possible to control what button was pressed without writing a SpeedButtonClick procedure for each button?
The OnClick method passes the Sender in as a TObject. You can hook all the buttons up to the same OnClick methods and check to see which button was clicked something like this:
procedure TForm1.SpeedButton1Click(Sender: TObject);
if Sender is TSpeedButton then
with Sender as TSpeedButton do
case GroupIndex of
This is assuming the GroupIndex of each button is unique.
<< Back to main page