iverson-3

1. 添加项目

checkedListBox1.Items.Add("一级");
checkedListBox1.Items.Add("二级");
checkedListBox1.Items.Add("三级");

 

2. 判断第i项是否被选中,选中为true,否则为false

if(checkedListBox1.GetItemChecked(i))
{
    return true;
} 
else
{
      return false; 
}

 

3. 设置第i项的选中状态

checkedListBox1.SetItemChecked(i, true); //true改为false为没有选中。

 

4. 获取选中项的值

foreach (string outstr in checkedListBox1.CheckedItems)
{
     MessageBox.Show(outstr);
}

 

5. 遍历选中项

for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
    if (checkedListBox1.GetItemChecked(i))
    {  
MessageBox.Show(checkedListBox1.GetItemText(checkedListBox1.Items[i]));
    }
}

 

分类:

技术点:

相关文章:

  • 2021-08-31
  • 2021-12-26
  • 2021-04-13
  • 2021-10-18
  • 2021-11-01
  • 2021-10-16
  • 2021-10-05
  • 2021-12-23
猜你喜欢
  • 2021-09-25
  • 2021-08-08
  • 2021-08-08
  • 2021-12-14
  • 2021-09-25
  • 2021-09-25
  • 2021-08-28
相关资源
相似解决方案