ListBox unselect items
<p>Want to unselect items on condition. I noticed that when do setselected then i get error on enxt loop because index was changed after first loop, therefore i decided to refresh and make everytime loop again but after one item is unselected i have invinitive loop for second one. How to accomplish that properly? Listbox is binded to datasource.</p>

<pre><code>sss:
        For i As Integer = 0 To ListBox1.SelectedItems.Count - 1
            Dim variationswert1 As DataRowView = ListBox1.SelectedItems(i)
            Dim name As String = ListBox1.GetItemText(variationswert1)
if name = "TR8" Then 
            ListBox1.SetSelected(i, False)
            ListBox1.Refresh()
            GoTo sss
End If
        Next
</code></pre>

<p><strong>EDIT: (for further discussion):</strong></p>

<pre><code> For i = 0 To ListBox1.Items.Count - 1
                If ListBox1.SelectedItems.Contains(ListBox1.Items(i))  Then

      MsgBox(ListBox1.GetItemText(ListBox1.Items(i)))
                MsgBox(ListBox1.SelectedValue.ToString)    

                    ListBox1.SetSelected(i, False)
                End If
            Next
            ListBox1.Refresh()
</code></pre>