Multi Select List Box

后端 未结 4 1830
名媛妹妹
名媛妹妹 2021-01-03 09:41

I have a list box on a form and it works fine for what I want to do.

I am wanting to edit items on the form, this means populating the listbox and then selecting the

4条回答
  •  天涯浪人
    2021-01-03 10:35

    Because my code had the following loops:

    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
    

    The first loop loops through the available sizes and the second loop is used to compare the item sizes.

    Having the following code:

    Else
     Me.lstItemSizes.SetSelected(i, False)
    End If
    

    Meant that even if item i became selected, it could also be deselected.

    SOLUTION: Remove Me.lstItemSizes.SetSelected(i, False) OR Include Exit For

提交回复
热议问题