foreach語句的變量操作不能在類型 「System.Windows.Controls.GroupBox」的變量操作,因爲 「System.Windows.Controls.GroupBox 「不包含公共 定義 '的GetEnumerator'foreach語句無法在類型「System.Windows.Controls.GroupBox」
mycode的:
foreach (var txt in this.groupBox1.Children)
{
if (txt is TextBox)
{
(txt as TextBox).Text = string.Empty;
}
}
但爲什麼是面向網格正確的代碼?
foreach (var txt in this.MyGrid.Children)
{
if (txt is TextBox)
{
(txt as TextBox).Text = string.Empty;
}
}
groupBox的正確代碼是什麼?
///////////////// 編輯
正確的代碼:
foreach (var txt in this.MyGridInGroupBox.Children)
{
if (txt is TextBox)
{
(txt as TextBox).Text = string.Empty;
}
}
不起作用:的for(int i = 0; I
mrJack
@mrJack「不行」如何? –
更新您的代碼後很漂亮。 – mrJack