日期:2014-05-18  浏览次数:21187 次

如何判断checkedListBox1中某一项是否选中?
如何判断checkedListBox1中某一项是否选中?

------解决方案--------------------
foreach(int indexChecked in checkedListBox1.CheckedIndices) 

foreach(object itemChecked in checkedListBox1.CheckedItems)

------解决方案--------------------
checkedListBox1.CheckedItems 是所有选中的项的集合,可以遍历它:

for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++)
listBox1.Items.Add(this.checkedListBox1.CheckedItems[i].ToString());


如果你只想判断某一已知项是否被选中,可以这样判断:

if (checkedListBox1.CheckedItems.IndexOf(checkedListBox1.Items[3])>=0)
MessageBox.Show("第4项:"+checkedListBox1.Items[3]+"被选中");