2 // System.Windows.Forms.NumericUpDown.cs
5 // stubbed out by Paul Osman (paul.osman@sympatico.ca)
6 // Dennis Hayes (dennish@raytek.com)
7 // Alexandre Pigolkine (pigolkine@gxm.de)
9 // (C) 2002/3 Ximian, Inc
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.ComponentModel;
33 namespace System.Windows.Forms {
39 public class NumericUpDown : UpDownBase, ISupportInitialize {
41 private decimal Value_ = 0;
42 private int DecimalPlaces_;
43 private bool Hexadecimal_ = false;
44 private decimal Increment_ = 1;
45 private decimal Maximum_ = 100;
46 private decimal Minimum_ = 0;
51 public NumericUpDown()
56 public override void DownButton(){
57 if( Value_ > Minimum_) {
58 Value = Math.Max(Value_ - Increment_, Minimum_);
63 // --- Public Properties
67 public int DecimalPlaces {
69 return DecimalPlaces_;
73 DecimalPlaces_ = value;
78 public bool Hexadecimal {
88 public decimal Increment {
98 public decimal Maximum {
104 if( Maximum_ != value) {
106 Minimum = Math.Min(Maximum_,Minimum_);
107 Value = Math.Min(Value_,Minimum_);
113 public decimal Minimum {
119 if( Minimum_ != value) {
121 Maximum = Math.Max(Maximum_,Minimum_);
122 Value = Math.Max(Value_,Minimum_);
128 public override string Text {
129 //FIXME: just to get it to run
131 return Value_.ToString();
134 Value = Decimal.Parse(value);
139 public bool ThousandsSeparator {
141 throw new NotImplementedException ();
149 public decimal Value {
155 if( Value_ != value) {
163 // --- Public Methods
167 public override string ToString()
170 return base.ToString();
174 public override void UpButton()
176 if( Value_ != Maximum_) {
177 Value = Math.Min(Value_ + Increment_, Maximum_);
185 public event EventHandler ValueChanged;
188 // --- Protected Methods
191 protected override AccessibleObject CreateAccessibilityInstance()
194 return base.CreateAccessibilityInstance();
198 protected override void OnTextBoxKeyPress(object source, KeyPressEventArgs e)
201 base.OnTextBoxKeyPress(source, e);
205 protected virtual void OnValueChanged(EventArgs e)
211 protected void ParseEditText()
217 protected override void UpdateEditText()
220 base.Text = Value_.ToString();
224 protected override void ValidateEditText()
227 base.ValidateEditText();
230 void ISupportInitialize.BeginInit(){
234 void ISupportInitialize.EndInit(){