日期:2014-05-17  浏览次数:20853 次

checkListBox控件、

  拖了个checklistbox控件,集合里添加了几个值,我想循环打印出当前选择的几个值的索引、怎么打印?

------解决方案--------------------
for(int i=0;i<checklistbox.Itmes.Count;i++)
{
MessageBox.Show(i.ToString());
}
------解决方案--------------------
for (int i = 0; i < checkedListBox1.SelectedIndices.Count;i++ )
{
MessageBox.Show(checkedListBox1.SelectedIndices[i].ToString());
}
------解决方案--------------------
C# code
for (int i = 0; i < checkedListBox1.SelectedItems.Count;i++ )
  {
  MessageBox.Show(checkedListBox1.SelectedItems[i].ToString());
  }

------解决方案--------------------
for (int i = 0; i < checkedListBox1.Items.Count; i++) {
if (checkedListBox1.GetItemChecked(i)) {
MessageBox.Show(i.ToString());
}
}