Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to scroll a listview by code

Status
Not open for further replies.

chiuchimuN

Programmer
Apr 24, 2002
29
US
Iv'e seen the code in this forum but could find it in the search.

Basically I want to move the visible listitems up or down in code(scroll). The MSDN help file index does this,WinAmp playlist does this, and so does Access tables.
 
Kurage,

I don't know if I understand you correctly, but this is some code that I use to allow the user to scroll through the listview using the up and down arrow keys.

Put this code in the Key_Down event of the listview.

Dim indx As Integer
indx = ListView2.SelectedItem.Index

'MsgBox KeyCode
'up arrow key
If KeyCode = 38 Then
If indx = 1 Then Exit Sub
ListView2.SelectedItem = ListView2.ListItems(indx - 1)
End If
If KeyCode = 40 Then 'down arrow
If indx = ListView2.ListItems.Count Then Exit Sub
ListView2.SelectedItem = ListView2.ListItems(indx + 1)
End If

tsmith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top