Class SfNumericTextBox
Represents a text box control that to allow only numeric inputs and display the numeric values with various formats such as numeric, percent and currency.
Inheritance
Namespace: Syncfusion.WinForms.Input
Assembly: Syncfusion.SfInput.WinForms.dll
Syntax
public class SfNumericTextBox : TextBox, IThemeProvider, IVisualStyle
Examples
This example shows how to initialize the SfNumericTextBox control.
//Initializing new instance of the SfNumericTextBox.
SfNumericTextBox sfNumericTextBox = new SfNumericTextBox();
//Initializing the location of the SfNumericTextBox.
sfNumericTextBox.Location = new System.Drawing.Point(348, 71);
//Initializing the name of the SfNumericTextBox.
sfNumericTextBox.Name = "sfNumericTextBox";
//Initializing the size of the SfNumericTextBox.
sfNumericTextBox.Size = new System.Drawing.Size(94, 30);
//Initializing the value of the SfNumericTextBox.
sfNumericTextBox.Value = 1.23;
//Initializing the format mode of the SfNumericTextBox.
sfNumericTextBox.FormatMode = FormatMode.Currency;
Constructors
SfNumericTextBox()
Initializes a new instance of the SfNumericTextBox class.
Declaration
public SfNumericTextBox()
Properties
AccessibilityEnabled
Gets or sets a value indicating whether the SfNumericTextBox control should enable its Accessibility support.
Declaration
public bool AccessibilityEnabled { get; set; }
Property Value
Type |
---|
System.Boolean |
AllowNull
Gets or sets a value indicating whether the null value is allowed in SfNumericTextBox.
Declaration
public bool AllowNull { get; set; }
Property Value
Type |
---|
System.Boolean |
BackColor
Gets or sets the back color property of System.Windows.Forms.TextBox.
Declaration
public Color BackColor { get; set; }
Property Value
Type |
---|
System.Drawing.Color |
BaseThemeName
Gets or sets the BaseThemeName of the control.
Declaration
protected string BaseThemeName { get; set; }
Property Value
Type |
---|
System.String |
CanApplyTheme
Gets or sets a value indicating whether a
Declaration
public bool CanApplyTheme { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is true. |
CanOverrideStyle
Gets or sets a value indicating whether control elements styles can be overridden by theme style settings.
Declaration
public bool CanOverrideStyle { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Default value is false. |
Remarks
By default, the control's element styles will not be overridden by theme style settings if the style is set in sample level. If this property is enabled, element style will be overridden by theme style settings event if it is set in sample level. This property should be enabled or disabled before calling the ThemeName property of the control.
ControlName
Gets the name of the control.
Declaration
public string ControlName { get; }
Property Value
Type |
---|
System.String |
CreateParams
Encapsulates the styles and other information while creating the control.
Declaration
protected override CreateParams CreateParams { get; }
Property Value
Type |
---|
System.Windows.Forms.CreateParams |
Font
Overrides the base class font property.
Declaration
public override Font Font { get; set; }
Property Value
Type |
---|
System.Drawing.Font |
FormatMode
Gets or sets the mode type for Value which defines how the value needs to be formatted, where formatting is done using NumberFormatInfo.
Declaration
public FormatMode FormatMode { get; set; }
Property Value
Type |
---|
FormatMode |
Remarks
If Mode specified as Currency, then value formatted based on currency format setting of NumberFormatInfo. If Mode specified as Percent, then value formatted based on percent format setting of NumberFormatInfo. If Mode specified as Numeric, then value formatted based on numeric format setting of NumberFormatInfo.
HideTrailingZeros
Gets or sets a value indicating whether the trailing zeros should be displayed or not.
Declaration
public bool HideTrailingZeros { get; set; }
Property Value
Type |
---|
System.Boolean |
InterceptArrowKeys
Gets or sets a value indicating whether the user can use the UP ARROW and DOWN ARROW keys to select values.
Declaration
public bool InterceptArrowKeys { get; set; }
Property Value
Type |
---|
System.Boolean |
IsVisualStyleEnabled
Gets a value indicating whether the visual style based theme is applied to the control and also indicates whether the theme files are referred from external assemblies or not.
Declaration
public bool IsVisualStyleEnabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Return true, if the visual style based theme is applied to the control. Otherwise returns false. |
LostFocusValidation
Gets or sets mode which defines how the Value need to be reset after validation fails when ValidationMode is set to LostFocus.
Declaration
public ValidationResetOption LostFocusValidation { get; set; }
Property Value
Type |
---|
ValidationResetOption |
MaxValue
Gets or sets the maximum value for the SfNumericTextBox.
Declaration
public double MaxValue { get; set; }
Property Value
Type |
---|
System.Double |
MinValue
Gets or sets the minimum value for the SfNumericTextBox.
Declaration
public double MinValue { get; set; }
Property Value
Type |
---|
System.Double |
NumberFormatInfo
Gets or sets the formatting information for the Value, using this formatting and parsing the numeric values can be done.
Declaration
public NumberFormatInfo NumberFormatInfo { get; set; }
Property Value
Type |
---|
System.Globalization.NumberFormatInfo |
Prefix
Gets or sets the value to prepend the string to the formatted text.
Declaration
public string Prefix { get; set; }
Property Value
Type |
---|
System.String |
Style
Gets or sets the NumericTextBoxVisualStyle value to customize the appearance of the Textbox.
Declaration
public NumericTextBoxVisualStyle Style { get; set; }
Property Value
Type |
---|
NumericTextBoxVisualStyle |
Suffix
Gets or sets the value to append the string to the formatted text.
Declaration
public string Suffix { get; set; }
Property Value
Type |
---|
System.String |
Text
Overrides the Text property of System.Windows.Forms.TextBox.
Declaration
public override string Text { get; set; }
Property Value
Type |
---|
System.String |
ThemeName
Gets or sets the theme name of the Numeric TextBox control.
Declaration
public string ThemeName { get; set; }
Property Value
Type | Description |
---|---|
System.String | The default value is null. |
Remarks
The theme will be applied only when the particular theme for this control has included the Themes assembly.
ValidationMode
Declaration
public ValidationMode ValidationMode { get; set; }
Property Value
Type |
---|
ValidationMode |
Value
Declaration
public double? Value { get; set; }
Property Value
Type |
---|
System.Nullable<System.Double> |
ValueChangeMode
Gets or sets the mode which define when the Value should be changed and ValueChanged event should be called.
Declaration
public ValueChangeMode ValueChangeMode { get; set; }
Property Value
Type |
---|
ValueChangeMode |
VisualTheme
Gets or sets the visualTheme of the control, which holds the ThemeName applied from SkinManager
Declaration
protected string VisualTheme { get; set; }
Property Value
Type |
---|
System.String |
WatermarkText
Gets or sets the content which should be displayed when Value is empty and the control is not in focus.
Declaration
public string WatermarkText { get; set; }
Property Value
Type |
---|
System.String |
Methods
CreateAccessibilityInstance()
Creates a new accessibility object for the control.
Declaration
protected override AccessibleObject CreateAccessibilityInstance()
Returns
Type | Description |
---|---|
System.Windows.Forms.AccessibleObject | A new System.Windows.Forms.AccessibleObject for the control. |
GetActiveThemeName()
Gets the active theme name of the SfNumericTextBox control.
Declaration
public string GetActiveThemeName()
Returns
Type | Description |
---|---|
System.String | Returns the active theme name. |
OnEnabledChanged(EventArgs)
Raises the enable changed event of the SfNumericTextBox
Declaration
protected override void OnEnabledChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Events argument |
OnEnter(EventArgs)
Raises the enter event of the Textbox
Declaration
protected override void OnEnter(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Events argument |
OnForeColorChanged(EventArgs)
Raises the System.Windows.Forms.Control.ForeColorChanged event.
Declaration
protected override void OnForeColorChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | An System.EventArgs that contains the event data. |
OnGotFocus(EventArgs)
Got Focus
Declaration
protected override void OnGotFocus(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event Args |
OnLayout(LayoutEventArgs)
Layout method
Declaration
protected override void OnLayout(LayoutEventArgs levent)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.LayoutEventArgs | levent | Layout EventArgs |
OnLeave(EventArgs)
Raises when the TextBox lost focus
Declaration
protected override void OnLeave(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Events argument |
OnLostFocus(EventArgs)
Lost focus
Declaration
protected override void OnLostFocus(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event Args |
OnMouseDown(MouseEventArgs)
Mouse down
Declaration
protected override void OnMouseDown(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.MouseEventArgs | e | Mouse EventArgs |
OnMouseEnter(EventArgs)
Activates the mouse enter event for the control
Declaration
protected override void OnMouseEnter(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event args |
OnMouseLeave(EventArgs)
Activates the mouse leave event for the control
Declaration
protected override void OnMouseLeave(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event args |
OnPaint(PaintEventArgs)
Override for Paint event
Declaration
protected override void OnPaint(PaintEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.PaintEventArgs | e | Paint event argument |
OnTextChanged(EventArgs)
Text changed event
Declaration
protected override void OnTextChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event argument |
OnValueChanged(ValueChangedEventArgs)
Raises the ValueChanged event.
Declaration
protected virtual void OnValueChanged(ValueChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
ValueChangedEventArgs | e | A ValueChangedEventArgs that contains the event data. |
Paste()
Pastes the data in the clipboard into the NumberTextBox control.
Declaration
protected virtual void Paste()
Remarks
The data will be formatted before being pasted into the text box.
ProcessKeyEventArgs(ref Message)
Overrides to suppress KeyPress. Only the KeyPress event is raised - no other processing is done.
Declaration
protected override bool ProcessKeyEventArgs(ref Message m)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Message | m | The message. |
Returns
Type | Description |
---|---|
System.Boolean | True if the message is a KeyPress; otherwise the base class handles this. |
ProcessKeyMessage(ref Message)
This method overrides the System.Windows.Forms.Control.ProcessKeyMessage(System.Windows.Forms.Message@) method and handles the key messages that are of interest to the NumberTextBox.
Declaration
protected override bool ProcessKeyMessage(ref Message m)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Message | m | The message that is to handled. |
Returns
Type | Description |
---|---|
System.Boolean | True if the key message is handled; false otherwise. |
ShouldSerializeMinValue()
Serialize the minimum value
Declaration
protected bool ShouldSerializeMinValue()
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the minimum value is set to its default value |
ShouldSerializeValidationMode()
Serialize the ValidationMode
Declaration
protected bool ShouldSerializeValidationMode()
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the ValidationMode is set to its default value |
ShouldSerializeValue()
Serialize the value
Declaration
protected bool ShouldSerializeValue()
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the value is 0.0 |
WndProc(ref Message)
Window Procedure call back function
Declaration
protected override void WndProc(ref Message m)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Message | m | Gives the Windows message |
Events
ThemeChanged
Occurs when theme name of the SfNumericTextBox has changed.
Declaration
public event ThemeChangedEventHandler ThemeChanged
Event Type
Type |
---|
ThemeChangedEventHandler |
ThemeNameChanged
Occurs when theme name of the SfNumericTextBox has changed.
Declaration
public event ThemeChangedEventHandler ThemeNameChanged
Event Type
Type |
---|
ThemeChangedEventHandler |
ValueChanged
Occurs when the Value property has been changed.
Declaration
public event ValueChangedEventHandler ValueChanged
Event Type
Type |
---|
ValueChangedEventHandler |
Explicit Interface Implementations
IVisualStyle.VisualTheme
Gets or sets the VisualTheme of the SfNumericTextBox control.
Declaration
string IVisualStyle.VisualTheme { get; set; }
Returns
Type |
---|
System.String |
IThemeProvider.BaseThemeName
Gets or sets the BaseTheme name of the theme
Declaration
string IThemeProvider.BaseThemeName { get; set; }
Returns
Type |
---|
System.String |