This is because the controls in a container such as a groupbox or panel belong to the container's controls collection, not the form's control's collection. You need to recurse through the container's collections if you want to get them all
private void SetClickHandler(Control.ControlCollection controls) {
foreach (var button in controls.OfType<Control>()) {
button.Click += button_Click;
if (button.Controls.Count > 0)
SetClickHandler(button.Controls);
}
}
private void Form1_Load(object sender, EventArgs e) {
SetClickHandler(Controls);
}