I am programming an instrument controller in which the user needs to be able to enter values for particular instrument parameters. One such parameter is Number of Samples
. I need to restrict user input according to specified a min, max, and increment:
Min: 32
Inc: 32
Max: 2097120
Therefore, the possible values it can be are:
32, 64, 96, 128, 160, ..., 2097120
I've contemplated using a ComboBox
, but with this many items it will not only be slow to load the list, but it will be frustrating for the user to select a value among such a large list.
I've also thought about using a NumericUpDown
, but the Increment
parameter only controls the increment applied when pressing the up or down arrows. The value of the control doesn't coerce to the specified increment. For example, if I type in 38, it should coerce to the nearest possible value, which is 32. If I type in 58, it should coerce to 64.
Is there a control that would allow me to do what I want? Or would I have to inherit from NumericUpDown
and handle the value changed event to coerce the value? Maybe there's a special ComboBox
implementation that only loads part of the list and continues to load the rest as the user scrolls, so they don't have to wait how ever long for the entire list to load?
Thanks.
Edit: I'm going with extending the NumericUpDown class to provide what I want. Thanks for the help!