roidy said:
How do I detect when a user scrolls a ListView control?
Thanks
Rob
You need to create a usercontrol derived from the listview. In this control
you will override the WndProc and raise an event when the WM_VSCROLL is
sent.
Follow these steps:
1. Add a new usercontrol and call it something like MyListView
2. In the MyListView.Designer.vb file change the inherits clause to:
Inherits System.Windows.Forms.ListView
As soon as you have done that you will see errors in the
InitializeComponent sub. Just comment or delete those two lines
3. In the code file for MyListView use the following code:
Public Class MyListView
Public Event ProcMsg(ByVal m As Message)
Public Const WM_VSCROLL As Integer = 277
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_VSCROLL
RaiseEvent ProcMsg(m)
End Select
MyBase.WndProc(m)
End Sub
End Class
4. Build your project , this will add the MyListView control to the
toolbox.
5. Now add a MyListView control to your form.
6. Add code to handle the ProcMsg event. Since you didn't say what you
were going to do when this occurred this is where I stop.
Hope this helps
LS