Subject: Listview doesnt change after items are selected.
Posted By: hexOffender Post Date: 12/13/2006 11:28:18 AM
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).Text)
                Dim g As New Guid(ListView1.SelectedItems.Item(0).SubItems(3).Text)
                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.



Go to topic 45395

Return to index page 95
Return to index page 94
Return to index page 93
Return to index page 92
Return to index page 91
Return to index page 90
Return to index page 89
Return to index page 88
Return to index page 87
Return to index page 86