Link to home
Start Free TrialLog in
Avatar of Swamp_Thing
Swamp_ThingFlag for United States of America

asked on

trap up/down arrow click event from updowncontrol

I have a VisualStudio 2008 / VisualBasic 2008 (.Net) application with a form that includes a numeric up/down control.  I need to trap the up/down arrow click so that I can programmatically increment the value:
When the user uses the KBD (or cut-n-paste etc.) to enter/change the value the resulting value can be anything between min and max.
When the up/down arrow is used the resulting value must be the next higher/lower multiple of a specific increment - as long as it does not violate min or max ( if it does value is to remain unchanged ).
Increment = 12, Current value is 24, user can change value to 31
Increment = 12, Current value is 31, user clicks down arrow; resulting value is 24
Increment = 12, Current value is 31, user clicks up arrow; resulting value is 36
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
wow!!!!!!! ...You Dont exist!! :)
Lol...you figured me out jtoutou!  I'm a manifestation of the accumulated knowledge on the web.  I exist solely as a sentient digital entity in the bowels of the interwebs.  ;)
Avatar of Swamp_Thing

ASKER

It took a couple of tries to figure out where this code goes...   Initially I put it into one of my modules but no control showed up on the tools in design mode and the event didn't fire.  What worked was to paste the code into one of my forms .Designer.vb code at the very top - prior to the "<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _" and "Partial Class <formname>" etc. etc.
I did not need to drag-n-drop the new control onto my form:  I changed the .Designer.vb code from defining my existing control as “New System.Windows.Forms.NumericUpDown” to “New <MyProjectName>.MyNumericUpDown”
I'm not a novice but something along the lines of "cut-n-paste this code into the very beginning of your main forms .Designer.vb file" would have helped.

Crystal clear answer - 100% complete and accurate sample code!
Ah...there's more than one way to add the control to your project.  Just ask next time.  Glad it worked for you.  =)