listview selected

bshaen

Newcomer
Joined
Mar 10, 2005
Messages
19
i have a textbox field that allow user to enter the stdcode, after user press enter, listview.selecteditem will according what the user enter in the textbox field,

i have try this
ListView1.SelectedItems(i).Text = textbox1.text
but it's doesn't work, it's not highlight the selecteditems in listview1

can anyone tell me what wrong with my coding above? thank
 
try:
Visual Basic:
Dim i As Integer
For i = 0 to ListView1.Items.Count - 1
    If ListView1.Items(i).SubItems(0).Text = TextBox1.Text Then
        ListView1.Items(i).Selected = True
        Me.ActiveControl = Me.ListView1
        Exit For
    End If
Next

I think this is what you are asking for, but the most important part of the code is Me.ActiveControl = Me.ListView1 as you must give the ListView focus in order for the ListView to display the selected item.
 
Back
Top