惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
F
Full Disclosure
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threat Research - Cisco Blogs
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
博客园 - 【当耐特】
AWS News Blog
AWS News Blog
U
Unit 42
V
Vulnerabilities – Threatpost
P
Privacy International News Feed
T
Tor Project blog
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Recorded Future
Recorded Future
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
Latest news
Latest news
GbyAI
GbyAI
S
SegmentFault 最新的问题
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
Hacker News: Ask HN
Hacker News: Ask HN
美团技术团队
N
News | PayPal Newsroom
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
The Hacker News
The Hacker News
The GitHub Blog
The GitHub Blog
V
V2EX
N
News and Events Feed by Topic
T
Troy Hunt's Blog
Security Latest
Security Latest
博客园 - 叶小钗
P
Palo Alto Networks Blog

博客园 - codingsilence

更新部分字段 NHibernate 都是分号惹的祸(ORA-00911: invalid character) 降低Winform 内存占用 installshiled 创建iis应用程序池和站点 FARPOINT 常见用法 比较Double型数据时的注意事项 WinForm中获取鼠标当前位置 查看SQL Server日志 WinForm winform动态生成菜单 WinForm 从XML中动态加载菜单的示例 “轻松加愉快”地实现并使用IComparer接口 C#程序实现动态调用DLL的研究 WCF 的 WebGet 方式 WCF WebGet WebInvoke WCF Jquery 调用 开源选型关注点 在64位Windows的IIS上开启32位程序支持(转) Oracle grant用户授权 ODP.NET开发和部署的相关问题 Client使用c#和odp.net连接server oracle
WinForm 选择器
codingsilence · 2011-07-20 · via 博客园 - codingsilence

public static IEnumerable<T> GetControls<T>(this Control control, Func<T, bool> filter) where T : Control
        {
            foreach (Control c in control.Controls)
            {
                if (c is T && (filter == null || filter(c as T)))
                {
                    yield return c as T;
                }
                foreach (T _t in GetControls<T>(c, filter))
                    yield return _t;
            }
        }

        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
                action(item);
        }

//禁用所有Button
     this.GetControls<Button>(null).ForEach(b => b.Enabled = false);
     //反选groupBox1中CheckBox
     this.GetControls<CheckBox>(c => c.Parent == groupBox1)
         .ForEach(c => c.Checked = !c.Checked);
     //将label1的前景色设为红色
     this.GetControls<Label>(l => l.Name == "label1").FirstOrDefault().ForeColor
         = Color.Red;