我想从 checkedListBox
中获取项目进入List<>
,但没有全选/取消全选(第一个复选框)..无法弄清楚如何不添加第一项..
这是代码:
foreach (string s in checkedListBoxDepts.CheckedItems)
{
if (checkedListBoxDepts.SelectedItems.IndexOf(s) == 0)
continue;
list.Add(s);
}
然后我把这些项目放在另一个列表中以避免错误:
foreach (string s in list)
{
list2.Add(s);
}
但仍然加载全选...帮助
最佳答案
尝试:
foreach (var s in checkedListBoxDepts.CheckedItems)
{
if (checkedListBoxDepts.IndexOf(s) == 0)
continue;
list.Add(s.ToString());
}
关于c# - 循环遍历 checkedListBox 项目而不选择所有项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16851553/