Solved

Scrolling Listview through code?

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

691 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