title: Multi Select List Box
body: <p>I have a list box on a form and it works fine for what I want to do.</p>
  
  <p>I am wanting to edit items on the form, this means populating the listbox and then selecting the relevant items.</p>
  
  <p>My listbox contains a list of item sizes, i want to select the sizes which belong to the item being edited.</p>
  
  <p>PLease can someone give me some pointers.</p>
  
  <p>I tried <code>me.lstItemSizes.SetSelected(i,true)</code> but this only works for a single item.</p>
  
  <p>Any help wil be much appreciated.</p>
  
  <p>My Code:</p>
  
  <pre><code>    Private Sub SelectItemSizes(ByVal itemID As Integer)
  
      Dim itemSizes As IList(Of ItemSize) = _sizeLogic.GetItemSizes(itemID)
  
      Me.lstItemSizes.SelectionMode = SelectionMode.MultiExtended
  
      If (itemSizes.Count &gt; 0) Then
  
          For i As Integer = 0 To Me.lstItemSizes.Items.Count - 1
  
              For x As Integer = 0 To itemSizes.Count - 1
  
                  If (CType(Me.lstItemSizes.Items(i), PosSize).SizeID = itemSizes(x).SizeID) Then
                      Me.lstItemSizes.SetSelected(i, True)
                  Else
                      Me.lstItemSizes.SetSelected(i, False)
                  End If
  
              Next
  
          Next
  
      End If
  
  End Sub
  </code></pre>