Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mousewheel event with numericupdown control

Status
Not open for further replies.

Jrhaynes

Technical User
Oct 27, 2006
21
US
It seems to me that the mousewheel operates on the numericupdown control with a fixed increment of 3 no mater what increment is set for the control.

Is there a way to 1) control the increment change, or 2) simply disengage the mousewheel from having any effect.

I notice that the mousewheel event doesn't jive with the definitions, for example the 'delta' value is always plus or minus 120, not the change, and the 'clicks' value always records zero irrespective of the clicks.

Of course I could install an independent mousewheel event handler but I would prefer to use (or disable if unusable) the events already in place for the control.

Here is a simple form1 example. Examining this operation, I noticed that the mousewheel sends 3 separate increment value changes to the control when it is in focus.

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
NumericUpDown1.Minimum = CDec(0)
NumericUpDown1.Maximum = CDec(100)
NumericUpDown1.Increment = CDec(1)
End Sub

Private Sub NumericUpDown1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NumericUpDown1.MouseWheel
Dim c, d As Integer
c = e.Clicks
d = e.Delta
'c is always zero with wheel rotate or even with wheel click
'd is +120 or =120
End Sub
End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top