NumericUpDown control increment value change
-
I was trying to determine on how to get this to work. When clicking on either up or down, its already set to 0.1 increment/decrement value. However, when shift key is pressed and clicking either up or down, the increment would change to 1.0 increment/decrement. I've done the coding but it delayed the increment change. When I shift-click, I had to click twice on the up button for the step value to change. What's the effective way to get the step value to change upon the shift-click is detected?
-
I was trying to determine on how to get this to work. When clicking on either up or down, its already set to 0.1 increment/decrement value. However, when shift key is pressed and clicking either up or down, the increment would change to 1.0 increment/decrement. I've done the coding but it delayed the increment change. When I shift-click, I had to click twice on the up button for the step value to change. What's the effective way to get the step value to change upon the shift-click is detected?
Create your own class, derived from NumericUpDown. Override the UpButton and DownButton methods:
public class MyUpDown : NumericUpDown
{
public override void UpButton()
{
decimal save = Increment;
if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
{
Increment *= 10;
}
base.UpButton();
Increment = save;
}
public override void DownButton()
{
decimal save = Increment;
if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
{
Increment *= 10;
}
base.DownButton();
Increment = save;
}
}Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water