
Introduction
Numeric input has always been one of the key-features in many applications (CRM, Accounting,...). Although MS provides a masked edit control, many developers find it to have some limitations.
The Numeric TextBox tries to provide some features to allow the user to input numeric data in a natural way. Let's have a look at some of the key features.
- Allow/Disallow negative input.
- Specify the maximum precision and scale.
- Specify a different scale when the control hasn't got the focus.
- Allow/Disallow zero as a valid input.
- The control displays grouping characters.
- The control adapts the regional settings (grouping char, decimal char).
Using the code
To use the control simply reference theShorty.Windows.Forms
assembly in your project. Create (or drag and drop on the form) aNumericTextBox
and set the properties. The properties can be set trough code or via the property pane (Numeric settings section). See below for an example.
//// numericTextBox1//Shorty.Windows.Forms.NumericTextBox() numericTextBox1 =new Shorty.Windows.Forms.NumericTextBox();this.numericTextBox1.AllowNegative =true;this.numericTextBox1.DataBindings.Add(new System.Windows.Forms.Binding("NumericValue",this,"Table1.test"));this.numericTextBox1.NumericPrecision =8;this.numericTextBox1.NumericScaleOnFocus =5;this.numericTextBox1.NumericScaleOnLostFocus =3;this.numericTextBox1.NumericValue =0;this.numericTextBox1.ZeroIsValid =false;
The control automatically checks if the combinationNumericPrecision NumericScaleOn(Lost)Focus
is valid. As you can see in the above sample to retrieve the numeric value displayed in theNumericTextBox
you should use theNumericValue
property.The control is also capable of databinding it'sNumericValue
property. (See above code sample).
History
- Initial release version 0.1.0.0 (20/06/2004)
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be foundhere