Search code examples
c#winformsnumericupdown

NumericUpDown differentiate up and down


I have a WinForm with some numreicUpDown Controls, i want to know if the value has been incremented or decremented. the control fires the event value changed for both situations, and as far as i can understand the programm calls the methods UpButton and DownButton. Is there any other way to know how the value has been changed or do i have to do this with this methods(like firing eventor implementig my code in Up-Down-Button)


Solution

  • There is no standart way to do this. I sugest to remember the old value and compare it with new one

    decimal oldValue;
    
    private void ValueChanged(object sender, EventArgs e)
    {
        if (numericUpDown.Value > oldValue)
        {
        }
        else
        {
        }
        oldValue = numericUpDown.Value;
    }