Selected Listview Item (code vs. mouseclick)

Heiko

Well-known member
Joined
Feb 10, 2003
Messages
430
Location
Holstein, Germany.
Is there a difference between using this code

Code:
        lvw.Items(index).Selected = True

and the classical built-in user event of clicking on an item?

It seems so!
Because the row turns all blue, when clicked via mouse, but is greyed when selected via code.

Or did I miss something?

Any comments greatly appreciated :-)
 
If the listview is focused this problem shouldnt arise. Try setting the FocusedItem property as well as making that item selected.
 
i dont think you will highlight the listitem in the same way as clicking it, i think thats a WM_PAINT issue that happens when the mouse goes down, focusing / selecting the item will only highlight it a dull grey colour not dark blue / grey
 
ok i fixed it , i just give it a good test and mine highlights blue at the click of a button :
Code:
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        ListView1.Focus()
        ListView1.Items(3).Selected = True
        ListView1.Items(3).Focused = True
    End Sub
hope this helps :)
 
Back
Top