在winfrom中当点击groupbox1里的一个按钮时隐藏groupbox1显示groupbox2怎样写代码
1个回答
展开全部
var buttons = GetButtons(groupbox1);
Array.ForEach(buttons, button =>
{
button.Click += (sender, eventArgs) =>
{
groupbox1.Visible = false;
groupBox2.Visible = true;
};
});
/// <summary>
/// 返回子控件或是子控件的子控件中类型为button的控件
/// </summary>
/// <param name="control">The control.</param>
/// <returns></returns>
private static Control[] GetButtons(Control control)
{
var buttons = new List<Control>();
foreach (Control subControl in control.Controls)
{
if( subControl is Button )
buttons.Add(subControl);
buttons.AddRange(GetButtons(subControl));
}
return buttons.ToArray();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询