如果你想让可见 --> 不可见,反之亦然,使用这个 -foreach (Control c in Controls){ if (c.GetType() == typeof(Panel)) { // Invert the visibility state of the panel c.Visible = !c.Visible; }}