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

推荐订阅源

Google Online Security Blog
Google Online Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
Cisco Talos Blog
Cisco Talos Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Scott Helme
Scott Helme
Project Zero
Project Zero
E
Exploit-DB.com RSS Feed
S
Secure Thoughts
K
Kaspersky official blog
L
Lohrmann on Cybersecurity
NISL@THU
NISL@THU
WordPress大学
WordPress大学
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 热门话题
小众软件
小众软件
P
Privacy & Cybersecurity Law Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
Hacker News: Ask HN
Hacker News: Ask HN
AWS News Blog
AWS News Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hacker News: Front Page
F
Full Disclosure
Latest news
Latest news
Schneier on Security
Schneier on Security
The Hacker News
The Hacker News
T
Troy Hunt's Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Jina AI
Jina AI
Martin Fowler
Martin Fowler
P
Proofpoint News Feed
TaoSecurity Blog
TaoSecurity Blog
G
GRAHAM CLULEY
Forbes - Security
Forbes - Security
V
V2EX - 技术
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Vulnerabilities – Threatpost
C
Cyber Attacks, Cyber Crime and Cyber Security
MongoDB | Blog
MongoDB | Blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
P
Privacy International News Feed
C
Check Point Blog
N
News and Events Feed by Topic

博客园 - 残香恨

WinForm:如何设置DataGridView列标题对齐方式 ASP.NET WebForm开发WAP网站 lock语句的递归问题 VS 2010 调试 .NET Framework 源代码 最近遇到的两个问题 ASP.NET MVC 2 模板化辅助方法 SynchronizationContext对Windows Forms窗体控件的更新方法 - 残香恨 SQL Server 2008 Express 升级R2全过程 自定义ASP.NET MVC Html辅助方法 - 残香恨 将ASP.NET MVC 1.0升级到ASP.NET MVC 2的三种方法 - 残香恨 .NET 4.0:一段动态绑定代码的底层初级分析 - 残香恨 Visual Studio 2010 RTM版安装初体验 - 残香恨 .NET中的线程 .NET 4.0 任务(Task) C#4.0 动态绑定(Dynamic Binding) - 残香恨 .NET4.0新功能:任务(Task) - 残香恨 .NET4.0线程池的Cooperative Cancellation模式 - 残香恨 Visual Studio 2010 RC初体验 - 残香恨 SQL Server导入文本文件时选择相同数据类型的一个小技巧 - 残香恨
WinForm:如何在ListBox中添加CheckBox
残香恨 · 2010-09-24 · via 博客园 - 残香恨

  最近因为做WinForm的项目,遇到这个问题,当时以为CheckedListBox不能满足这个功能,所以采用了ListBox + CheckBox的组合。后来发现,CheckedListBox完全满足,但还是打算写在博客里,算是个总结。

  实现其实很简单,只是我们在通过ListBox的Controls属性添加CheckBox时,要设置CheckBox的Location值,不然,添加多个CheckBox会只显示一个。如下代码所示:

代码

string[] list = new string[] { "张三", "李四", "王五" };int x = 0, y = 0;
foreach (string item in list)
{
CheckBox cb
= new CheckBox();
cb.Text
= item;
cb.Location
= new Point(x, y);
clbInvisibleColumn.Controls.Add(cb);
y
+= 22;
}

  PS:本文纯属水文。