473,508 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to determine that a scroll event occured

I need to know when the user scrolls a Windows.Forms.Panel
either by using one of the scroll buttons or by using one
of the scrollbars. Are there any events or overridable
methods that can be used to detect this?

Thanks,
Lance
Nov 20 '05 #1
2 2573
Hi,

Check to see if the autoscrollpostion has changed in the paint event
of the panel. Or create an inherited control. Override wndproc you will
recieve the WM_HSCROLL or WM_VSCROLL messages when the panel scrolls.
<ToolboxBitmap(GetType(Panel))> _

Public Class PanelScroll

Inherits System.Windows.Forms.Panel

Public Event Scroll(ByVal sender As Object, ByVal e As EventType)

Private Const WM_VSCROLL = &H115

Private Const WM_HSCROLL = &H114

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

Me.HorizontalScrollbar = True

'Add any initialization after the InitializeComponent() call

End Sub

'UserControl1 overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

components = New System.ComponentModel.Container

End Sub

#End Region

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

Dim Bytes, b As Byte()

If m.Msg = WM_VSCROLL Or m.Msg = WM_HSCROLL Then

RaiseEvent Scroll(Me, New EventArgs)

End If

MyBase.WndProc(m)

End Sub

End Class

Ken
-------------------------
"Lance" <zi***@hotmail.com> wrote in message
news:04****************************@phx.gbl...
I need to know when the user scrolls a Windows.Forms.Panel
either by using one of the scroll buttons or by using one
of the scrollbars. Are there any events or overridable
methods that can be used to detect this?

Thanks,
Lance

Nov 20 '05 #2
Fantastic! Thanks a lot for the example.
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2685
by: _Andy_ | last post by:
I've seen this question asked before, but no answer is visible. Is it possible to determine when the user scrolls an auto-scroll panel?
3
4876
by: Peter Row | last post by:
Hi, I have created a user control consisting of a textbox and a separate vertical scroll bar. The textbox is filled with data. However there could be lots of data so I only fill the textbox...
1
3365
by: johnperkins | last post by:
I am curious as to why the scrollbar.scroll event gets called twice Here is an example of my code Private Sub vsbMoveCar_Scroll(ByVal sender As System.Object, ByVal e As...
3
15181
by: Urs Vogel | last post by:
Hi I'm looking for a way to trap the ListView's scroll events, in order to control page-wise loading of not bindable data. Any hints of how to achieve this? Thanks, Urs
5
4274
by: TS | last post by:
Is there a way in debug mode to determine what event caused the postback to occur without having an event handler for that event? thanks
0
1062
by: Martin | last post by:
Hi all, I'm trying to find an item scroll event for this listview, but I can't find it. I must be overlooking something... Tia, Martin
2
3234
by: deborder | last post by:
hi all, im building an httphandler and need to identify which event occured in the page is there a way to do so (beside context.Request.Form.Keys which catch the postback action) Thanks in...
2
4189
by: Michael Meckelein | last post by:
I get "Value of '3720' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum' exception if I remove rows in a dataGridView while scrolling from the top to the end of the grid...
1
5784
by: tc | last post by:
Hello Using .NET 2.0, What would be the best way to capture a scroll event from a list box? Thanks in advance Thomas
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.