Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
How to swap arrow buttons functionality on NumericUpDown control?

I want to swap the Up and Down arrows (functionality only, not the actual arrows) on NumericUpDown control. For example on clicking the UP arrow the value should decrease and similarly on clicking the Down arrow the value should increase.

I tried to inherit from NumericUpDown class and override UpButton() and DownButton(). I thought that simply swapping the code in between these two methods should work. But upon pasting the DownButton() code into overridden UpButton(),

public class MyCustomNumericUpDown : NumericUpDown
{
    public override void UpButton()
    {
        SetNextAcceleration();
        if (base.UserEdit)
        {
            ParseEditText();
        }

        decimal num = currentValue;
        try
        {
            num -= Increment;
            if (num < minimum)
            {
                num = minimum;
                if (Spinning)
                {
                    StopAcceleration();
                }
            }
        }
        catch (OverflowException)
        {
            num = minimum;
        }

        Value = num;
    }
}

the above program throws the following errors.

The name 'SetNextAcceleration' does not exist in the current context
The name 'currentValue' does not exist in the current context
The name 'minimum' does not exist in the current context
The name 'Spinning' does not exist in the current context
The name 'StopAcceleration' does not exist in the current context
The name 'minimum' does not exist in the current context

I see all these methods and variables are set to private in the base class. Which might be throwing these "does not exist" errors.

Anyone know how to do this? I just want the arrow buttons functionality swapped. For example on clicking the UP arrow the value should decrease and similarly on clicking the Down arrow the value should increase.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can derive from the NumericUpDown and override UpButton and DownButton methods like this (by calling base.TheOtherMethod to swap the functionality):

public class CrazyNumericUpDown : NumericUpDown
{
    public override void UpButton()
    {
        base.DownButton();
    }
    public override void DownButton()
    {
        base.UpButton();
    }
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!