Listbox incorrectly detecting selected items

Results 1 to 2 of 2

Thread: Listbox incorrectly detecting selected items

  1. #1
    Join Date
    Dec 1969

    Default Listbox incorrectly detecting selected items

    Hi! I have a listbox which when added with the same strings does not detect which item is selected in the following code snippet. It is set as multiple select mode. For example, if the table has 3 items consisting in the same string (say &#039;Testing&#039; in all 3 cases) and you select the third one only. The code below will not break when i=2 (i.e. lbOptionalDescriptions.Count-1 [since it is zero-based]) but it will break when i=0 (i.e. the first element NOT the third). I need to distinguish between them because for each element in this listbox (lbOptionalDescriptions) there is an element in another listbox (lbOptionalComments). So, for the 1st, 2nd, and 3rd elements in the 1st listbox there is a 1st, 2nd, 3rd element in the second listbox (lbOptionalComments) and the selected one (e.g. third) in the first listbox should remove that element and also the (e.g. third) element in the second listbox (lbOptionalComments)<BR>Thanks for your help,<BR><BR>Timothy<BR><BR>&#039;Code snippet<BR>&#039;TODO: Selected item not being recognized as such<BR>For i = lbOptionalDescriptions.Items.Count - 1 To 0 Step -1<BR> If lbOptionalDescriptions.Items(i).Selected = True Then<BR> lbOptionalComments.Items.RemoveAt(i)<BR> lbOptionalDescriptions.Items.Remove(lbOptionalDesc riptions.Items(i).ToString)<BR>End If<BR>Next i

  2. #2

    Default RE: Listbox incorrectly detecting selected items

    Is this considered an assignement or a conditional?<BR><BR>lbOptionalDescriptions.Items(i ).Selected = True

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts