I have a Windows form named Form1 and panel within this form named panel1. I use the panel only to place buttons there so that I can group them and
One option is to cast the object to a Button, but rather than doing the casting you can change how the event handler is assigned so that you don't need to cast in the first place:
foreach (var button in panel1.Controls.OfType
Then just change the signature of HandleClick to:
private void HandleClick(Button button, EventArgs e);