foreach (Control control in this.panel1)
{
//其他应用代码
}foreach (Control control in this.groupbox1)
{
//其他应用代码
}
为什么这两句会报一个错误
错误 1 “System.Windows.Forms.Panel”不包含“GetEnumerator”的公共定义,因此 foreach 语句不能作用于“System.Windows.Forms.Panel”类型的变量
错误 1 “System.Windows.Forms.GroupBox”不包含“GetEnumerator”的公共定义,因此 foreach 语句不能作用于“System.Windows.Forms.GroupBox”类型的变量
是什么原因?
以前写过这样的一个函数,现在一下子怎么也想不起来了。
{
//其他应用代码
}foreach (Control control in this.groupbox1)
{
//其他应用代码
}
为什么这两句会报一个错误
错误 1 “System.Windows.Forms.Panel”不包含“GetEnumerator”的公共定义,因此 foreach 语句不能作用于“System.Windows.Forms.Panel”类型的变量
错误 1 “System.Windows.Forms.GroupBox”不包含“GetEnumerator”的公共定义,因此 foreach 语句不能作用于“System.Windows.Forms.GroupBox”类型的变量
是什么原因?
以前写过这样的一个函数,现在一下子怎么也想不起来了。
{
//其他应用代码
} 加个.Controls
foreach (Control ctl in this.panel1.Controls)
{
}