?
Solved

Scrolling Listview through code?

Posted on 1998-12-16
3
Medium Priority
?
614 Views
Last Modified: 2013-12-26
I'm trying to scroll a listview that's in report mode. I'm using drag and drop but if the item the user wants to drop over is further down or up the list I want the user to be able to move the drag item just above or below the list and have the listview scroll automatically up or down accordingly. I don't want to use sendkeys or anything that will select an item in the listview. Just change the view. I'm currently trying to use the LVM_SCROLL Win API message. Here's my code:

Private Sub RLst_DragOver(Source As Control, x As Single, y As Single, State As Integer)
Dim result As Long

If y < 250 Then 'above the list so scroll up
    result = SendMessage(RLst.hwnd, LVM_SCROLL, 0, -1)
ElseIf y > 3850 Then 'below the list so scroll down
    result = SendMessage(RLst.hwnd, LVM_SCROLL, 0, 1)
End If
0
Comment
Question by:deal051298
  • 2
3 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1489027
Take a look at the EnsureVisible method of a listview.
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 800 total points
ID: 1489028
Here is a sample for a treeview. You can use a similar approach for a listview.
http://support.microsoft.com/support/kb/articles/q177/7/43.asp?FR=0
0
 

Author Comment

by:deal051298
ID: 1489029
Cool! Thanks Mirkwood! For others out there, I just did a hittest on the first and last viewable items on the list and if they hit I scrolled up or down by one accordingly by setting the previous/next item "EnsureVisible". I also tested to see if the hit was the first or last item in the list to make sure I got no "Out of bounds" errors. Throw in some doevents to make it look pretty and hey! up and running in no time.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question