NumericUpDown

Hello!

I've been working on this problem for days now... and I can't solve it. Here's the thing:

Is there any way to see when a numupdown value has decreased or increased
I am making a program, that, depending on the value of a NumUpDown control, counts the price of an item.

When a tab is entered (OnEnter) the NumUpDown control is activated. It's value is set to 100.

if(lenght >= 100 && lenght < 110)
{
  price = price + 2;
}
else if(lenght == 100 || lenght <= 99)
{
    price = 0;
}

The problem is that price gets increased even if a user pressed key down. Like
100 -> 101 - > 102 -> 103 -> 104 -> 105 the value increases
Now, if a user makes the NumUpDown value go down 105 -> 104 -> 103 it still makes the price increase, because the value is >= 100 && < 110

Is there any way to prevent that



Answer this question

NumericUpDown

  • AmandaJO

    Yes, you can add two buttons and textbox, it would be much more simpler logic.

    you just have to code click events of buttons.

    Thanks,

    Varun



  • Hybidder

    Or maybe I could add a textbox, and 2 buttons. Then limit textbox to numbers only and read only. one button would increase the number and other would do opposite.

    Is that possible


  • NumericUpDown