Listview doesnt change after items are selected.
I have a really strange problem with a listview on a windows form.I have a listview that lists employees, select an employee and hit the button to bring up a form with their information. If you select an item/click the button going down the listview, the program works correctly. BUT, if you try to select an item above one that you selected before, it will not populate the employee form. What really has me baffled is that it is not consistent, sometimes it works for three different selections, sometimes it only works for two different selections.
Is this a problem with the listview's Index Changed event?
Code:
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
'check selecteditem.length
If ListView1.SelectedItems.Count > 0 Then
Try
empLname = Trim(ListView1.SelectedItems.Item(0).Text)
empFname = Trim(ListView1.SelectedItems.Item(0).SubItems(1).T ext)
Dim g As New Guid(ListView1.SelectedItems.Item(0).SubItems(3).T ext)
empID = g
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.OKCancel, "Error!")
Exit Try
Exit Sub
Finally
End Try
End If
End Sub
I would appreciate any input here.
|