首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

念遍历窗口所有控件,切出现这个,求大侠

2013-07-16 
想遍历窗口所有控件,切出现这个,求大侠 public void GetAllControls(Control control){for (int i 0 i

想遍历窗口所有控件,切出现这个,求大侠
 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或者程序集引用,请问各路大侠该如何去解决
[解决办法]

引用:
Quote: 引用:

右键那个异常看看能不能解析出什么类库,加进去

不懂?怎么操作


你这个是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;


                    //
                }
            }
        }


[解决办法]
 

热点排行