/全选
private void button3_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
{
this.checkedListBox1.SetItemChecked(i, true);
}
}
//反选
private void button4_Click(object sender, EventArgs e)
{
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
if (checkedListBox1.GetItemChecked(i))
{
checkedListBox1.SetItemChecked(i, false);
}
else
{
checkedListBox1.SetItemChecked(i, true);
}
}
}
本文介绍了一个简单的C#代码示例,展示了如何在Listbox中实现全选和反选的功能。通过两个按钮点击事件,可以轻松地切换所有项目的选中状态。
1456

被折叠的 条评论
为什么被折叠?



