Reputation: 370
I'd like to use increment/decrement buttons in numeric control field to quickly span wide range of values. In order to do this I would like increment/decrement buttons to work as multiply/divide by constant.
One example would be to choose resistor values. In order to choose values in E12 series one would start with 1 and multiply it over and over by 10^(1/12). 12 being how many values per decade you need.
Is there a way to change the function of up/down buttons or do I need to write my own control?
Upvotes: 1
Views: 2510
Reputation: 6284
If you want the user to choose from a fixed list of values like the E12 resistor series, consider using a ring or enum instead of a numeric control (the list in a ring can be changed at runtime, the list in an enum cannot). Use the value of the ring or enum to look up the numeric value from an array.
If you want the user to be able to type an arbitrary value in the numeric control but also use increment/decrement buttons to scale the value upwards or downwards, you could use a numeric control whose increment/decrement buttons are visible but hide the numeric entry field behind a second numeric control with no buttons. Use the Value Changed event for the hidden control as shown in CharlesB's answer to update the value in the visible control when the user increments or decrements the hidden control.
Upvotes: 0
Reputation: 1164
Keeping it simple, just have the numeric control as an integer (say N), and wire up 10^(N/12).
Upvotes: 2
Reputation: 90456
You can do this by listening to "Value changed" event, that detects if increment or decrement was used, and force the appropriate value:
Upvotes: 0