Solved

Scrolling Listview through code?

Posted on 1998-12-16
3
591 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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 47
using web browser with BING 40 136
Set email body to html using vbscript 6 71
RUNRMTCMD from AS/400 13 101
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

733 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