Articles → .NET → Controlling NumericUpDown buttons in windows form in .NET

Controlling NumericUpDown buttons in windows form

in .NET




Introduction




Picture showing the windows numeric up down control in .net

Click to Enlarge






Implementation




public class NumericUpDownExtendedClass: NumericUpDown {}










public class NumericUpDownExtendedClass: NumericUpDown {
  public override void DownButton() {}
  public override void UpButton() {}
}






public class NumericUpDownExtendedClass: NumericUpDown {
  public enum ControlMode {
    Normal,
    Reverse
  }

  public ControlMode ModeType {
    get;
    set;
  }

  public override void DownButton() {}
  public override void UpButton() {}
}






public class NumericUpDownExtendedClass: NumericUpDown {
  public enum ControlMode {
    Normal,
    Reverse
  }

  public ControlMode ModeType {
    get;
    set;
  }

  public override void DownButton() {
    if (ModeType == ControlMode.Reverse) {
      if (this.Value < Maximum) {
        this.Value = this.Value + Increment;
        ((NumericUpDown)(this)).Text = this.Value.ToString();
      }
    }
    else {
      base.UpButton();
    }
  }
  public override void UpButton() {
    if (ModeType == ControlMode.Reverse) {
      if (this.Value > Minimum) {
        this.Value = this.Value - Increment;
        ((NumericUpDown)(this)).Text = this.Value.ToString();
      }
    }
    else {
      base.DownButton();
    }
  }
}






NumericUpDownExtendedClass extended = new NumericUpDownExtendedClass();
extended.ModeType = NumericUpDownExtendedClass.ControlMode.Reverse;
this.Controls.Add(extended);





Posted By  -  Karan Gupta
 
Posted On  -  Friday, December 30, 2011

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250