mark c

mark c

  • NA
  • 14
  • 48.5k

For loop is exited before completion

Mar 1 2011 10:31 PM
[code]for (int d = 0; d <= checkedListBox1.Items.Count -1; d++)
{
          if (checkedListBox1.GetItemChecked(d) == true)
          {
           checkedListBox1.Items.RemoveAt(d);
         }
               
}[/code]
The for loop is completed before it's suppose to end... Why is this? I checked all the items (~20) in the checkedListBox, but when I run this code, not all the items are removed; some are left over. Why is this? I even tried removing if(checkedListBox1.GetItemChecked).                                

Answers (3)