C# checkedListBox 全选与反选怎么做?
展开全部
//全选
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);
}
}
}
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);
}
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |