Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net - problem getting the ListIndex of ListView without clicking

Hi
I am trying to get the ListIndex of a ListVew without clicking it but the last two lines of the following code
cause errors.

 Sub Get_Row_Index_on_Mousehover()
        Dim LocalMousePosition As Point
        LocalMousePosition = Me.lsvAction.PointToClient(Cursor.Position)
        Debug.WriteLine("X = " & LocalMousePosition.X & ", " & LocalMousePosition.Y)

        Dim x As Integer = LocalMousePosition.X
        Dim y As Integer = LocalMousePosition.Y
        Dim returnValue As ListViewItem
        returnValue = Me.lsvAction.GetItemAt(x, y)

        MsgBox(returnValue.Index)
 
    End Sub
ASKER CERTIFIED SOLUTION
Avatar of Stephen Manderson
Stephen Manderson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Great answer. Thanks very much