Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27251

VS 2010 [RESOLVED] Error on setting checkstate in a CheckedListBox control

$
0
0
I have a CheckedListBox control that I fill with DataGridView Column HeaderText values. If these columns are visible, I would like to set the CheckedListBox Items to "Checked". My code is as follows:

Code:

For Each col As DataGridViewColumn In frmTimingP2P.dgvOverview.Columns
    If col.Visible = True Then
        For Each item In clbOverviewColumnOrder.Items
            Dim intItemIndex As Integer = clbOverviewColumnOrder.Items.IndexOf(item)
            If col.HeaderText = item.ToString Then
                clbOverviewColumnOrder.SetItemCheckState(intItemIndex, CheckState.Checked)
            End If
        Next
    End If
Next

Whenever this code runs, I get the following error:

"List that this enumerator is bound to has been modified. An enumerator can only be used if the list does not change."

What causes this? How can I get around this issue?

Thanks

Viewing all articles
Browse latest Browse all 27251

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>