Question

I have a string, which contains words. I loop through these words and if it can be found in my listbox items i want to make it selected.

Dim word As String
            For Each word In words 'If it's null then do nothing
                If String.IsNullOrEmpty(word) Then
                Else

                    For l_index = 0 To DriveList.Items.Count - 1
                        If CStr(DriveList.Items(l_index)).Contains(word & ":\ drive") Then
                 How to select it???
                        End If
                    Next
                End If
            Next
        End If

Notice: DriveList.Items(l_index).selected or DriveList.Items(l_index).setselected is not working, there is no member like that. I use VS2012 and my app is running on .NET 4.5.

Was it helpful?

Solution 2

Okey guys,

this did the trick:

  DriveList.SelectedItems.Add(DriveList.Items(l_index).ToString())

OTHER TIPS

DriveList.Items(l_index)).Selected = True

Should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top