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或者程序集引用,请问各路大侠该如何去解决

解决方案 »

  1.   

    问题出在UserControl1,这是一个用户控件吗?在用户控件里面写的遍历方法?
      

  2.   

    对啊,我也知道是UserControl1,但是不知道是什么问题
      

  3.   

    用户控件应该继承自 UserControl
     public partial class UserControl1 : UserControl
      

  4.   

     public void GetAllControls(Control control)应该放你这个传进来的参数吧
      

  5.   

    不懂?怎么操作你这个是wpf应用程序吧?wpf没有controls属性。
    refer:
    public void GetAllControls()
            {
                UIElementCollection Childrens = this.Grid1.Children;
                foreach (UIElement element in Childrens)
                {
                    if (element is Button)
                    {
                        Button temp = element as Button;
                        //
                    }
                }
            }
      

  6.   

    不懂?怎么操作你这个是wpf应用程序吧?wpf没有controls属性。
    refer:
    public void GetAllControls()
            {
                UIElementCollection Childrens = this.Grid1.Children;
                foreach (UIElement element in Childrens)
                {
                    if (element is Button)
                    {
                        Button temp = element as Button;
                        //
                    }
                }
            }
    只是winform而已
      

  7.   

    不懂?怎么操作你这个是wpf应用程序吧?wpf没有controls属性。
    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的问题
      

  8.   

     <Grid Name="Grid1">
            <Button Name="button1" Width="50" Height="20">打开</Button>
        </Grid>起个名字Grid1
      

  9.   

    不懂?怎么操作你这个是wpf应用程序吧?wpf没有controls属性。
    refer:
    public void GetAllControls()
            {
                UIElementCollection Childrens = this.Grid1.Children;
                foreach (UIElement element in Childrens)
                {
                    if (element is Button)
                    {
                        Button temp = element as Button;
                        //
                    }
                }
            }
    只是winform而已
    回错了,不好意思,就像这样
      

  10.   

    ?????
    你分清楚你写的是什么吗??为啥在winform,wpf这个范围你用system.web 空间下的Control定义,这当然是找不到滴
      

  11.   

    看来是我的VS少了很多功能,
    不会啊,这是必须有的吧,那只能说明this里没有这个对象
      

  12.   

    应该是这个问题...
    你确保一下你继承的 类 Window 有没有 Control 这个属性...