register Mouse wheel handler in main VB .net 2005 form

I

ingmar

Hi,

how do I register my Mouse wheel handler in my main VB .net 2005 form?
My function

Private Sub Me_MouseWheel(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel

never gets called. What do I need to do to tell VB that this function
should handle the mouse wheel event?

In the designer, on the events list I do not have a MouseWheel event,
only MouseUp, MouseDown, MouseEnter, MouseLeave, MouseHover, MouseMove.
If I could get MouseWheel into this my problems are most likely
resolved.

Thanks for any help

Ingmar
 
I

ingmar

I just read to a number of related posts.
The best I could find was to add a function like:

Protected Overrides Sub OnMouseWheel(ByVal e As
System.Windows.Forms.MouseEventArgs)
Me_MouseWheel(Me, e)
End Sub

However, this also seems to never get called :-(
 
H

Herfried K. Wagner [MVP]

ingmar said:
how do I register my Mouse wheel handler in my main VB .net 2005 form?
My function

Private Sub Me_MouseWheel(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel

never gets called.

Replace 'Me.MouseWheel' with 'MyBase.MouseWheel' or alternatively override
the form's 'OnMouseWheel' method.
 
F

françois

To get the mouse event from a panel or a picture box (vb.net) you first must give the focus to the panel or the picture box. Because it cannot be done by simply clicking on the control, you have to do it by program.

Private Sub PictureBox1_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
PictureBox1.Focus()
End Sub

Private Sub pictureBox1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseWheel
' your process
End Sub

From http://www.developmentnow.com/g/38_...use-wheel-handler-in-main-VB-net-2005-form.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top