Click here to Skip to main content
15,886,676 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Image is here↓


https://i.stack.imgur.com/nMh6s.png[^]

If the plus button is clicked above, then the value should be plus in Numericupdown as well. If the minus button is clicked above, then the value should be minus in Numericupdown as well. I want to code inside C#.


What I have tried:

This is how it happens in the ones I've done

If the value of Numericupdown is 20 and I click plus button then 20 plus happens

ex: 20 + 20
But I don't want to do that

If the value of Numericupdown is 20 and I click on the plus button then 1 should be plus

ex: 20 + 1
Posted
Updated 12-Dec-22 19:13pm

1 solution

Why?
You already have an "up" and a "down" button (on the immediate left of your NumericUpDown Control) so all you are doing is adding redundant buttons which at best confuses users ...

But ... if you must then it's trivial: handle each new "up" and "down" button, and add or subtract 1 from MyNumericUpDown.Value.
I can't see your code, but it's probably something like:
C#
MyNumericUpDown.Value += MyNumericUpDown.Value;
and it should be
C#
MyNumericUpDown.Value += 1m;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900