public void GetAllControls(Control control)
{
for (int i = 0; i < this.Controls.Count; i++)
{
foreach (System.Web.UI.Control control in this.Controls[i].Controls)
{
if (control is TextBox)
(control as TextBox).Text = "";
}
}
}
在this.Controls出现缺少using或者程序集引用,请问各路大侠该如何去解决
{
for (int i = 0; i < this.Controls.Count; i++)
{
foreach (System.Web.UI.Control control in this.Controls[i].Controls)
{
if (control is TextBox)
(control as TextBox).Text = "";
}
}
}
在this.Controls出现缺少using或者程序集引用,请问各路大侠该如何去解决
public partial class UserControl1 : UserControl
refer:
public void GetAllControls()
{
UIElementCollection Childrens = this.Grid1.Children;
foreach (UIElement element in Childrens)
{
if (element is Button)
{
Button temp = element as Button;
//
}
}
}
refer:
public void GetAllControls()
{
UIElementCollection Childrens = this.Grid1.Children;
foreach (UIElement element in Childrens)
{
if (element is Button)
{
Button temp = element as Button;
//
}
}
}
只是winform而已
refer:
public void GetAllControls()
{
UIElementCollection Childrens = this.Grid1.Children;
foreach (UIElement element in Childrens)
{
if (element is Button)
{
Button temp = element as Button;
//
}
}
}
恩,我用的是WPF应用程序,但是你上面给我的代码中Crid1同样出现缺少using的问题
<Button Name="button1" Width="50" Height="20">打开</Button>
</Grid>起个名字Grid1
refer:
public void GetAllControls()
{
UIElementCollection Childrens = this.Grid1.Children;
foreach (UIElement element in Childrens)
{
if (element is Button)
{
Button temp = element as Button;
//
}
}
}
只是winform而已
回错了,不好意思,就像这样
你分清楚你写的是什么吗??为啥在winform,wpf这个范围你用system.web 空间下的Control定义,这当然是找不到滴
不会啊,这是必须有的吧,那只能说明this里没有这个对象
你确保一下你继承的 类 Window 有没有 Control 这个属性...