3
Reply

For loop is exited before completion

mark c

mark c

Mar 1 2011 10:31 PM
1.7k
[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)