Solved

Scrolling Listview through code?

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBS file using code from 2nd file (txt or vbs) 4 36
vb6 connector to SQL Server 2 37
Excel Automation VBA 19 70
VB6 - Scroll Mouse wheel on Picturebox 13 44
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 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