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 the Shorty.Windows.Forms
assembly in your project.
Create (or drag and drop on the form) a NumericTextBox
and set the properties.
The properties can be set trough code or via the property pane (Numeric settings section).
See below for an example.
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 combination NumericPrecision NumericScaleOn(Lost)Focus
is valid.
As you can see in the above sample to retrieve the numeric value displayed in the NumericTextBox
you should use
the NumericValue
property.
The control is also capable of databinding it's NumericValue
property. (See above code sample).
History
- Initial release version 0.1.0.0 (20/06/2004)