
新手请教各位大侠:在C#winfrom程序,自定义控件中,怎么遍历groupbox中的控件(比如多个按钮)?
3个回答
展开全部
foreach (System.Windows.Forms.Control control in this.groupBox1.Controls)//遍历groupBox1上的所有控件
{
if (control is System.Windows.Forms.Button) //如果是button
{
//////////////////////////////
}
}
{
if (control is System.Windows.Forms.Button) //如果是button
{
//////////////////////////////
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
int buttonNumber;
foreach (Control c in groupbox.Controls )
{
if (c is Button)
buttonNumber++;
}
不知道这样行不行………
foreach (Control c in groupbox.Controls )
{
if (c is Button)
buttonNumber++;
}
不知道这样行不行………
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
foreach(Control var in groupbox.Controls)
{
}
{
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询