Solved

Scrolling Listview through code?

Posted on 1998-12-16
3
581 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 200 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VBA Check for Character 9 70
VB6 convert MSHFlexgrid1 cells no2 2 51
Problem to the message 13 63
Adding to a VBA? 6 48
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now