Getting MouseWheel Event in UserControl

  • Thread starter Thread starter Adrian Game
  • Start date Start date
A

Adrian Game

Hi to all that read,

I have created a usercontrol for which i want to be able to use the mouse
wheel. Currently I have to make the form that the control is used in pass
the mousewheel event to the control by code. Is there any way to
automatically get the event for when the mouse is over the control area.

Cheers and thank in addvance for any help provided

Adrian
 
Put this finction in your Usercontrol:

Protected Overrides Sub OnMouseWheel(ByVal e As _
System.Windows.Forms.MouseEventArgs)
....
End Sub

Note that this event won't be raised unless your "usercontrol" has the focus
when the mouse wheel is used. However, you can set the focus to your user
control in the "OnMouseHover" event:

Protected Overrides Sub OnMouseHover(ByVal e As System.EventArgs)
Me.Focus()
End Sub
 

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

Back
Top