关于避免重复输入

就如以上这张图,我有 32 个按钮控件,为了实现代码的功能,怎么简化代码
private void SetVisible(Control control) { foreach (Control c in control.Controls) { if (c.HasChildren) { SetVisible(c); } else { var btn = c as Button; if (btn != null) btn.Visible = false; } } }