Murray Brown
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_Mousehove r()
Dim LocalMousePosition As Point
LocalMousePosition = Me.lsvAction.PointToClient (Cursor.Po sition)
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
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_Mousehove
Dim LocalMousePosition As Point
LocalMousePosition = Me.lsvAction.PointToClient
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER