码迷,mamicode.com
首页 > 其他好文 > 详细

LINQ递归控件

时间:2014-08-07 18:30:21      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:blog   for   ar   div   log   type   ad   har   

private void SetTextReadOnly(Control ctr, bool blReadOnly)
        {
            ctr.Controls.Cast<Control>().Select(s => s).ToList<Control>().ForEach(s =>
                {
                    if (s.GetType() == typeof(TextBox))
                        ((TextBox)s).ReadOnly = blReadOnly;

                    if (s.HasChildren)
                    {
                        SetTextReadOnly(s, blReadOnly);
                    }
                });

            //foreach (Control c in ctr.Controls)
            //{
            //    if (c.GetType() == typeof(TextBox))
            //    {
            //        ((TextBox)c).ReadOnly = true;
            //    }
            //    if (c.HasChildren)
            //    {
            //        SetTextReadOnly(c, blReadOnly);
            //    }
            //}
        }

  

LINQ递归控件,布布扣,bubuko.com

LINQ递归控件

标签:blog   for   ar   div   log   type   ad   har   

原文地址:http://www.cnblogs.com/zfanlong1314/p/3897431.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!