【解決方法】プラスとマイナスのボタンをnumericupdownに接続するには?


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#.

私が試したこと:

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

例: 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

例: 20 + 1

解決策 1

なんで?
すでに「上」ボタンと「下」ボタン (NumericUpDown コントロールのすぐ左) があるため、ユーザーを混乱させる冗長なボタンを追加するだけです …

しかし…必要がある場合は簡単です。新しい「上」および「下」ボタンをそれぞれ処理し、から1を加算または減算します MyNumericUpDown.Value.
あなたのコードは見えませんが、おそらく次のようなものです。

C#
MyNumericUpDown.Value += MyNumericUpDown.Value;

そしてそれはあるべきです

C#
MyNumericUpDown.Value += 1m;

コメント

タイトルとURLをコピーしました