WinForm使用反射通过控件的name得到该控件

            object obj = this.GetType().GetField("控件名称", 
                System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance 
                | System.Reflection.BindingFlags.IgnoreCase).GetValue(this);
            Label lbl = (Label)obj; 

 

 

posted @ 2012-11-21 17:22  古兰色回忆  阅读(4002)  评论(1编辑  收藏  举报