alexa
menu

WinForms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download

    Show / Hide Table of Contents

    Class CurrencyTextBox

    Extends the System.Windows.Forms.TextBox class to handle currency input and validation.

    Inheritance
    System.Object
    TextBoxExt
    NumberTextBoxBase
    CurrencyTextBox
    GridCurrencyTextBox
    Implements
    IThemeProvider
    IVisualStyle
    System.ComponentModel.ISupportInitialize
    System.Runtime.Serialization.ISerializable
    Inherited Members
    NumberTextBoxBase.AllowNull
    NumberTextBoxBase.ApplyFormattingAndSetText(String, String)
    NumberTextBoxBase.ApplyRightToLeft()
    NumberTextBoxBase.BackColor
    NumberTextBoxBase.BackGroundColor
    NumberTextBoxBase.BindableValue
    NumberTextBoxBase.BindableValueChanged
    NumberTextBoxBase.CanUndo
    NumberTextBoxBase.CheckDecimalPartLength(String)
    NumberTextBoxBase.CheckForMinMax(String)
    NumberTextBoxBase.CheckNullStringIsInRange(String)
    NumberTextBoxBase.ClipMode
    NumberTextBoxBase.ClipText
    NumberTextBoxBase.ClipTextChanged
    NumberTextBoxBase.CompleteInsertString(NumberModifyState)
    NumberTextBoxBase.CompleteSubtractKey(NumberModifyState)
    NumberTextBoxBase.ControlValidated
    NumberTextBoxBase.Copy()
    NumberTextBoxBase.Culture
    NumberTextBoxBase.CurrentCultureRefresh
    NumberTextBoxBase.CursorShouldBeMoved(Int32, Boolean)
    NumberTextBoxBase.Cut()
    NumberTextBoxBase.DefaultValue
    NumberTextBoxBase.Delete()
    NumberTextBoxBase.DeleteSelectedText()
    NumberTextBoxBase.DeleteSelectedText(String, Int32, Int32)
    NumberTextBoxBase.EndInit()
    NumberTextBoxBase.EnforceMinMaxDuringValidating
    NumberTextBoxBase.ForeColor
    NumberTextBoxBase.FormattedText
    NumberTextBoxBase.FormattedTextChanged
    NumberTextBoxBase.GetClipText()
    NumberTextBoxBase.GetClipText(Boolean)
    NumberTextBoxBase.GetCopyOfCurrentNumberFormatInfo()
    NumberTextBoxBase.GetDecimalSeparator()
    NumberTextBoxBase.GetDecimalSeparatorPosition(String, NumberFormatInfo)
    NumberTextBoxBase.GetFirstDataPos()
    NumberTextBoxBase.GetGroupSeparator()
    NumberTextBoxBase.GetInitialZeroCount(String, Int32)
    NumberTextBoxBase.GetNegativeInputPending()
    NumberTextBoxBase.GetNextDataPos(Int32, Boolean, Boolean, Boolean)
    NumberTextBoxBase.GetNumberPartLength(String)
    NumberTextBoxBase.GetPreserveData()
    NumberTextBoxBase.GetPrevDataPos(Int32)
    NumberTextBoxBase.GetTextBoxText()
    NumberTextBoxBase.GetTextBoxTextLength()
    NumberTextBoxBase.GetZeroNegative()
    NumberTextBoxBase.HandleBackspaceKeyChar()
    NumberTextBoxBase.HandleSubtractKey()
    NumberTextBoxBase.HideTrailingZeros
    NumberTextBoxBase.ignoreTextChange
    NumberTextBoxBase.initNumberFormatInfoObject
    NumberTextBoxBase.InsertString(String, Int32, Int32, String)
    NumberTextBoxBase.InsertString(String, Int32, Int32, String, Boolean)
    NumberTextBoxBase.IsNegative
    NumberTextBoxBase.IsNull
    NumberTextBoxBase.IsValidCharacter(Char)
    NumberTextBoxBase.IsValidNumberValue(String)
    NumberTextBoxBase.KeyValidate
    NumberTextBoxBase.m_bDecimalMode
    NumberTextBoxBase.MaxLength
    NumberTextBoxBase.MinMaxValidation
    NumberTextBoxBase.NegativeColor
    NumberTextBoxBase.NegativeInputPendingOnSelectAll
    NumberTextBoxBase.NegativeSign
    NumberTextBoxBase.NullFormat
    NumberTextBoxBase.NullState
    NumberTextBoxBase.NullString
    NumberTextBoxBase.NumberFormatInfoObject
    NumberTextBoxBase.OnBackColorChanged(EventArgs)
    NumberTextBoxBase.OnBindableValueChanged(EventArgs)
    NumberTextBoxBase.OnClipTextChanged(EventArgs)
    NumberTextBoxBase.OnControlValidated(String, String)
    NumberTextBoxBase.OnFormattedTextChanged(EventArgs)
    NumberTextBoxBase.OnKeyValidate(KeyValidateEventArgs)
    NumberTextBoxBase.OnMouseDown(MouseEventArgs)
    NumberTextBoxBase.OnReadOnlyChanged(EventArgs)
    NumberTextBoxBase.OnSetNull(SetNullEventArgs)
    NumberTextBoxBase.OnValidationError(ValidationErrorArgs)
    NumberTextBoxBase.OnValidationFailed
    NumberTextBoxBase.OverWriteText
    NumberTextBoxBase.ParseForNegativeFormat(String)
    NumberTextBoxBase.Paste()
    NumberTextBoxBase.PositiveColor
    NumberTextBoxBase.ProcessKeyEventArgs(Message)
    NumberTextBoxBase.ProcessKeyMessage(Message)
    NumberTextBoxBase.RaiseKeyValidate(Char, String, String)
    NumberTextBoxBase.RaiseSetNull(Object)
    NumberTextBoxBase.RaiseValidationError(String, Int32)
    NumberTextBoxBase.RaiseValidationError(String, Int32, String)
    NumberTextBoxBase.ReadOnlyBackColor
    NumberTextBoxBase.RefreshCulture()
    NumberTextBoxBase.RemoveFormatting(String)
    NumberTextBoxBase.RemoveFormatting(String, Boolean)
    NumberTextBoxBase.RemoveFormatting(String, NumberFormatInfo)
    NumberTextBoxBase.ResetControlBackColor()
    NumberTextBoxBase.ResetForeColor()
    NumberTextBoxBase.ResetNegativeColor()
    NumberTextBoxBase.ResetPositiveColor()
    NumberTextBoxBase.ResetReadOnlyBackColor()
    NumberTextBoxBase.ResetRightToLeft()
    NumberTextBoxBase.ResetZeroColor()
    NumberTextBoxBase.ReturnBaseText
    NumberTextBoxBase.RightToLeft
    NumberTextBoxBase.rollBackOperation
    NumberTextBoxBase.SelectAll()
    NumberTextBoxBase.SelectAllOnFocus
    NumberTextBoxBase.SelectedText
    NumberTextBoxBase.SetControlColor()
    NumberTextBoxBase.SetDefaultValue(Object)
    NumberTextBoxBase.SetEmptySelection(Int32)
    NumberTextBoxBase.SetModifiedText(String, String)
    NumberTextBoxBase.SetNegativeInputPending(Boolean)
    NumberTextBoxBase.SetNull
    NumberTextBoxBase.SetPreserveData(Boolean)
    NumberTextBoxBase.SetTextBoxText(String, String)
    NumberTextBoxBase.SetZeroNegative(Boolean)
    NumberTextBoxBase.ShouldSerializeNegativeColor()
    NumberTextBoxBase.ShouldSerializeNegativeSign()
    NumberTextBoxBase.ShouldSerializePositiveColor()
    NumberTextBoxBase.ShouldSerializeZeroColor()
    NumberTextBoxBase.SpecialCultureValue
    NumberTextBoxBase.supressKeyPress
    NumberTextBoxBase.Undo()
    NumberTextBoxBase.UseNullString
    NumberTextBoxBase.UseUserOverride
    NumberTextBoxBase.Validate(Boolean)
    NumberTextBoxBase.ValidationError
    NumberTextBoxBase.WndProc(Message)
    NumberTextBoxBase.ZeroColor
    TextBoxExt.ApplyScaleToControl(Single)
    TextBoxExt.BeforeTouchSize
    TextBoxExt.BeginInit()
    TextBoxExt.Border3DStyle
    TextBoxExt.Border3DStyleChanged
    TextBoxExt.BorderColor
    TextBoxExt.BorderColorChanged
    TextBoxExt.BorderSides
    TextBoxExt.BorderSidesChanged
    TextBoxExt.CanApplyTheme
    TextBoxExt.CanOverrideStyle
    TextBoxExt.CharacterCasing
    TextBoxExt.CharacterCasingChanged
    TextBoxExt.ControlName
    TextBoxExt.CornerRadius
    TextBoxExt.CreateParams
    TextBoxExt.DefWndProc(Message)
    TextBoxExt.DrawActiveWhenDisabled
    TextBoxExt.EnableTouchMode
    TextBoxExt.FarImage
    TextBoxExt.FocusBorderColor
    TextBoxExt.Font
    TextBoxExt.GetActiveThemeName()
    TextBoxExt.Initializing
    TextBoxExt.ISerializable.GetObjectData(SerializationInfo, StreamingContext)
    TextBoxExt.IsVisualStyleEnabled
    TextBoxExt.IThemeProvider.BaseThemeName
    TextBoxExt.IVisualStyle.VisualTheme
    TextBoxExt.MaximumSize
    TextBoxExt.MaximumSizeChanged
    TextBoxExt.Metrocolor
    TextBoxExt.MinimumSize
    TextBoxExt.MinimumSizeChanged
    TextBoxExt.NCOverflowIndicatorPaint(Graphics, Rectangle, Rectangle)
    TextBoxExt.NearImage
    TextBoxExt.Office2007ColorScheme
    TextBoxExt.Office2007ColorTable
    TextBoxExt.Office2010ColorScheme
    TextBoxExt.Office2010ColorTable
    TextBoxExt.OnBorder3DStyleChanged(EventArgs)
    TextBoxExt.OnBorderColorChanged(EventArgs)
    TextBoxExt.OnBorderSidesChanged(EventArgs)
    TextBoxExt.OnBorderStyleChanged(EventArgs)
    TextBoxExt.OnCanApplyThemeChanged(Boolean)
    TextBoxExt.OnCanOverrideStyleChanged(Boolean)
    TextBoxExt.OnCharacterCasingChanged(EventArgs)
    TextBoxExt.OnFontChanged(EventArgs)
    TextBoxExt.OnHandleCreated(EventArgs)
    TextBoxExt.OnHandleDestroyed(EventArgs)
    TextBoxExt.OnLostFocus(EventArgs)
    TextBoxExt.OnMaximumSizeChanged(EventArgs)
    TextBoxExt.OnMinimumSizeChanged(EventArgs)
    TextBoxExt.OnMouseEnter(EventArgs)
    TextBoxExt.OnMouseLeave(EventArgs)
    TextBoxExt.OnMultilineChanged(EventArgs)
    TextBoxExt.OnPaint(PaintEventArgs)
    TextBoxExt.OnParentChanged(EventArgs)
    TextBoxExt.OnSizeChanged(EventArgs)
    TextBoxExt.OnThemesEnabledChanged(EventArgs)
    TextBoxExt.OverflowIndicatorToolTip
    TextBoxExt.OverflowIndicatorToolTipText
    TextBoxExt.RaiseThemeChanged(Object, ThemeChangedEventArgs)
    TextBoxExt.ShowOverflowIndicator
    TextBoxExt.ShowOverflowIndicatorToolTip
    TextBoxExt.Style
    TextBoxExt.ThemeName
    TextBoxExt.ThemeNameChanged
    TextBoxExt.ThemesEnabled
    TextBoxExt.ThemesEnabledChanged
    TextBoxExt.UseBorderColorOnFocus
    Namespace: Syncfusion.Windows.Forms.Tools
    Assembly: Syncfusion.Shared.Base.dll
    Syntax
    public class CurrencyTextBox : NumberTextBoxBase, IThemeProvider, IVisualStyle, ISupportInitialize, ISerializable
    Remarks

    The CurrencyTextBox is derived from the textbox and provides all the functionality of a text box and adds additional functionality of its own.

    Collecting currency input in a consistent format requires a lot of validation code that needs to be built into the application when using the Windows Forms textbox control. The CurrencyTextBox includes all this logic into its methods and properties and makes it easy for the developer and the end user to collect and enter currency data.

    The CurrencyTextBox is also closely tied to the globalization settings of the operating system for Currency related properties. Please refer to the System.Globalization.NumberFormatInfo class for a detailed explanation of globalization and Currency related attributes.

    The CurrencyTextBox has full support for the Windows Forms designer and you can just drag-and-drop and set properties on the control just as you would with the Windows Forms textbox.

    The CurrencyTextBox also raises a ValidationError event when inappropriate data is entered into the control.

    All clipboard functions such as copy, paste and cut are also supported with special accommodations for currency related issues.

    Examples
       // Create the Calculator Control.
       this.currencyTextBox1 = new CurrencyTextBox();
    
       // Set the initial value.
       this.currencyTextBox1.Text = "$1.00";
    
       // Set the clipmode.
       this.currencyTextBox1.ClipMode = CurrencyClipModes.IncludeFormatting;
    
       // Set formatting properties.
       this.currencyTextBox1.CurrencyDecimalDigits = 2;
       this.currencyTextBox1.CurrencyDecimalSeparator = ".";
       this.currencyTextBox1.CurrencyGroupSeparator = ",";
       this.currencyTextBox1.CurrencyGroupSizes = new int[] {3};
       this.currencyTextBox1.CurrencyNegativePattern = 1;
       this.currencyTextBox1.CurrencyNumberDigits = 27;
       this.currencyTextBox1.CurrencyPositivePattern = 0;
       this.currencyTextBox1.CurrencySymbol = "$";
       this.currencyTextBox1.ForeColor = System.Drawing.Color.Black;
       this.currencyTextBox1.NegativeColor = System.Drawing.Color.Red;
       this.currencyTextBox1.NegativeSign = "-";
       this.currencyTextBox1.PositiveColor = System.Drawing.Color.Black;
    
       this.currencyTextBox1.Size = new System.Drawing.Size(256, 20);
       this.currencyTextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
    
       // Add the CurrencyTextBox control to the form.
       this.Controls.Add(this.currencyTextBox1);

    Constructors

    CurrencyTextBox()

    Overloaded. Creates an object of type CurrencyTextBox.

    Declaration
    public CurrencyTextBox()
    Remarks

    The CurrencyTextBox object will be initialized with the default values for the display and data properties. You need to set any specific values.

    Fields

    MaxNumberLength

    The maximum number of valid digits the textbox can take. This is set to the maximum value a decimal type can hold.

    Declaration
    public static int MaxNumberLength
    Field Value
    Type
    System.Int32

    Properties

    AccessibilityEnabled

    Gets or sets a value indicating whether the control should enable its Accessibility support.

    Declaration
    public bool AccessibilityEnabled { get; set; }
    Property Value
    Type
    System.Boolean

    CurrencyDecimalDigits

    The maximum number of digits for the decimal portion of the currency.

    Declaration
    public int CurrencyDecimalDigits { get; set; }
    Property Value
    Type
    System.Int32
    Remarks

    The US dollar requires 2 decimal points to accomodate the smallest denomination and this property will have the value 2 in this case. If there is a need to have a different value based on the locale, it will be automatically changed based on the current locale.

    CurrencyDecimalSeparator

    The decimal separator character that will be used for the display.

    Declaration
    public string CurrencyDecimalSeparator { get; set; }
    Property Value
    Type
    System.String
    Remarks

    This value is initially set from the System.Globalization.NumberFormatInfo and can be changed based on your requirements or based on the locale.

    CurrencyGroupSeparator

    This property specifies the separator to be used for grouping digits.

    Declaration
    public string CurrencyGroupSeparator { get; set; }
    Property Value
    Type
    System.String
    Remarks

    This value is initially set from the System.Globalization.NumberFormatInfo and can be changed based on your requirements or based on the locale.

    CurrencyGroupSizes

    This property specifies the grouping of CurrencyDigits in the CurrencyTextBox.

    Declaration
    public int[] CurrencyGroupSizes { get; set; }
    Property Value
    Type
    System.Int32[]
    Remarks

    This value is initially set from the System.Globalization.NumberFormatInfo and can be changed based on your requirements or based on the locale.

    CurrencyNegativePattern

    This property specifies the pattern to use when the value is negative.

    Declaration
    public int CurrencyNegativePattern { get; set; }
    Property Value
    Type
    System.Int32
    Remarks

    This value is initially set from the System.Globalization.NumberFormatInfo and can be changed based on your requirements or based on the locale.

    CurrencyNegativePatterns

    Declaration
    protected string[] CurrencyNegativePatterns { get; set; }
    Property Value
    Type
    System.String[]

    CurrencyNumberDigits

    The number of digits for the number part. This is not part of the globalization structure.

    Declaration
    public int CurrencyNumberDigits { get; set; }
    Property Value
    Type
    System.Int32
    Remarks

    This value is initially set based on the maximum value of the Currency data type.

    CurrencyPositivePattern

    This property specifies the pattern to use when the value is positive.

    Declaration
    public int CurrencyPositivePattern { get; set; }
    Property Value
    Type
    System.Int32
    Remarks

    This value is initially set from the System.Globalization.NumberFormatInfo and can be changed based on your requirements or based on the locale.

    CurrencySymbol

    This property specifies the currency symbol to be used in the CurrencyTextBox.

    Declaration
    public string CurrencySymbol { get; set; }
    Property Value
    Type
    System.String
    Remarks

    This value is initially set from the System.Globalization.NumberFormatInfo and can be changed based on your requirements or based on the locale.

    DecimalValue

    The decimal value of the control. This will be formatted and displayed.

    Declaration
    public decimal DecimalValue { get; set; }
    Property Value
    Type
    System.Decimal

    MaxValue

    The Maximum Value that can be set through the CurrencyTextBox.

    Declaration
    public decimal MaxValue { get; set; }
    Property Value
    Type
    System.Decimal
    Remarks

    The default value is the MaxValue for System.Decimal.

    MinValue

    The Minimum Value that can be set through the CurrencyTextBox.

    Declaration
    public decimal MinValue { get; set; }
    Property Value
    Type
    System.Decimal

    NumberDigits

    The number of digits for the number part. This is not part of the globalization structure.

    Declaration
    public int NumberDigits { get; set; }
    Property Value
    Type
    System.Int32
    Remarks

    This value is initially set based on the maximum value of the Currency data type.

    RemoveDecimalZeros

    Gets or sets remove last decimal zeros.

    Declaration
    public bool RemoveDecimalZeros { get; set; }
    Property Value
    Type
    System.Boolean

    Text

    Overrides the Text property of System.Windows.Forms.TextBox.

    Declaration
    public override string Text { get; set; }
    Property Value
    Type
    System.String
    Remarks

    This property is overriden in order to normalize the data that is set to the Text property and format it as needed. The method InsertString(String, Int32, Int32, String, Boolean) is used to format the data.

    ThemeStyle

    Gets or sets the CurrencyTextBoxVisualStyle value used to customize the appearance of the CurrencyTextBox.

    Declaration
    public CurrencyTextBoxVisualStyle ThemeStyle { get; set; }
    Property Value
    Type
    CurrencyTextBoxVisualStyle
    Remarks

    This ThemeStyle setting will be applied only when the VisualStyleBased theme has been applied to the control.

    Methods

    ApplyFormatting(String)

    Format the given text according to the current setting.

    Declaration
    protected override string ApplyFormatting(string rawValue)
    Parameters
    Type Name Description
    System.String rawValue
    Returns
    Type
    System.String
    Overrides
    NumberTextBoxBase.ApplyFormatting(String)

    CanInsert(String, String, Int32)

    Checks if the text can be inserted subject to the constraints.

    Declaration
    protected override int CanInsert(string currentText, string inputText, int initialZeroCount)
    Parameters
    Type Name Description
    System.String currentText

    The current content of the TextBox.

    System.String inputText

    The text to be inserted.

    System.Int32 initialZeroCount
    Returns
    Type Description
    System.Int32

    The length of the acceptable string to be inserted.

    Overrides
    NumberTextBoxBase.CanInsert(String, String, Int32)

    CheckForMinMax(Decimal)

    Checks whether the specified decimal value falls within the defined minimum and maximum range.

    Declaration
    protected bool CheckForMinMax(decimal numericValue)
    Parameters
    Type Name Description
    System.Decimal numericValue

    The decimal value to validate.

    Returns
    Type
    System.Boolean

    CheckForMinMax(String, Boolean)

    Validates whether the specified text value falls within the allowed minimum and maximum range.

    Declaration
    protected override bool CheckForMinMax(string currentTextValue, bool ignoreLength)
    Parameters
    Type Name Description
    System.String currentTextValue

    The formatted string representing the numeric value.

    System.Boolean ignoreLength

    If true, validation is based solely on the numeric value. If false, length-based validation may be considered (though currently deprecated).

    Returns
    Type
    System.Boolean
    Overrides
    NumberTextBoxBase.CheckForMinMax(String, Boolean)

    CheckIfNegative(String)

    Determines whether the specified raw string value represents a negative decimal number.

    Declaration
    protected override bool CheckIfNegative(string rawValue)
    Parameters
    Type Name Description
    System.String rawValue

    The raw string input to evaluate.

    Returns
    Type
    System.Boolean
    Overrides
    NumberTextBoxBase.CheckIfNegative(String)

    CheckIsZero()

    Checks whether the value is zero.

    Declaration
    protected override bool CheckIsZero()
    Returns
    Type Description
    System.Boolean

    True, if value is zero.

    Overrides
    NumberTextBoxBase.CheckIsZero()

    ConcatModifiedText(String, String, String)

    Concatenates the modified text segments for the CurrencyTextBox control, applying formatting rules when decimal zeros are removed.

    Declaration
    protected override string ConcatModifiedText(string startCurrentText, string inputRawText, string endCurrentText)
    Parameters
    Type Name Description
    System.String startCurrentText

    The text before the new input.

    System.String inputRawText

    The raw input text entered by the user.

    System.String endCurrentText

    The text after the new input.

    Returns
    Type
    System.String
    Overrides
    NumberTextBoxBase.ConcatModifiedText(String, String, String)

    CreateAccessibilityInstance()

    Creates an accessibility instance for the control, returning a custom accessibility object if accessibility is enabled.

    Declaration
    protected override AccessibleObject CreateAccessibilityInstance()
    Returns
    Type
    System.Windows.Forms.AccessibleObject
    Overrides
    TextBoxExt.CreateAccessibilityInstance()

    CurrencyFormattedText(NumberFormatInfo, String, String, out Decimal)

    Gets the currency formatted text and the decimal value for a given NumberFormatInfo object and text value.

    Declaration
    public static string CurrencyFormattedText(NumberFormatInfo nfi, string currencyText, string nullString, out decimal dValue)
    Parameters
    Type Name Description
    System.Globalization.NumberFormatInfo nfi

    The NumberFormatFormatInfo object to be used for the formatting.

    System.String currencyText

    The text to be formatted.

    System.String nullString

    The value to be returned if the currencyText is considered a NULL value. This should be NULL if the string is not to be formatted as NULL even if value is NULL.

    System.Decimal dValue

    The decimal value.

    Returns
    Type
    System.String

    Dispose(Boolean)

    Releases the unmanaged resources used by the CurrencyTextBox and optionally releases the managed resources.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing

    true to release both managed and unmanaged resources; false to release only unmanage resources.

    Overrides
    NumberTextBoxBase.Dispose(Boolean)

    FormatChanged(String, NumberFormatInfo)

    Declaration
    protected override void FormatChanged(string currentText, NumberFormatInfo previousFormat)
    Parameters
    Type Name Description
    System.String currentText
    System.Globalization.NumberFormatInfo previousFormat
    Overrides
    NumberTextBoxBase.FormatChanged(String, NumberFormatInfo)

    GetControlName(String)

    Helps to override the ThemeName property settings

    Declaration
    public override string GetControlName(string controlName)
    Parameters
    Type Name Description
    System.String controlName

    ThemeName

    Returns
    Type
    System.String
    Overrides
    TextBoxExt.GetControlName(String)

    GetDecimalDigits()

    Gets the number of decimal digits used in the currency format.

    Declaration
    protected override int GetDecimalDigits()
    Returns
    Type
    System.Int32
    Overrides
    NumberTextBoxBase.GetDecimalDigits()

    GetDecimalSeparator(NumberFormatInfo)

    Override this to return CurrencyDecimalSeparator in CurrencyTextBox and PercentDecimalSeparator in PercentTextBox.

    Declaration
    protected override string GetDecimalSeparator(NumberFormatInfo info)
    Parameters
    Type Name Description
    System.Globalization.NumberFormatInfo info
    Returns
    Type
    System.String
    Overrides
    NumberTextBoxBase.GetDecimalSeparator(NumberFormatInfo)

    GetDecimalSeparatorPosition(String)

    Returns the position of the decimal separator taking into account the CurrencySymbol.

    Declaration
    protected override int GetDecimalSeparatorPosition(string currentText)
    Parameters
    Type Name Description
    System.String currentText

    The text in which to look for the decimal separator.

    Returns
    Type Description
    System.Int32

    The decimal separator's position.

    Overrides
    NumberTextBoxBase.GetDecimalSeparatorPosition(String)

    GetGroupSeparator(NumberFormatInfo)

    Override this to return CurrencyDecimalSeparator in CurrencyTextBox and PercentGroupSeparator in PercentTextBox.

    Declaration
    protected override string GetGroupSeparator(NumberFormatInfo info)
    Parameters
    Type Name Description
    System.Globalization.NumberFormatInfo info
    Returns
    Type
    System.String
    Overrides
    NumberTextBoxBase.GetGroupSeparator(NumberFormatInfo)

    GetNumberPartLength(Decimal)

    Gets the length of the numeric part of the specified decimal value.

    Declaration
    protected int GetNumberPartLength(decimal numberValue)
    Parameters
    Type Name Description
    System.Decimal numberValue

    The decimal number to evaluate.

    Returns
    Type
    System.Int32

    GetNumberValue(String, Int32)

    Extracts and parses the numeric value from the formatted currency text starting at the specified position.

    Declaration
    protected override string GetNumberValue(string formattedText, int startPosition)
    Parameters
    Type Name Description
    System.String formattedText

    The formatted currency string.

    System.Int32 startPosition

    The position in the string from which to begin extraction.

    Returns
    Type
    System.String
    Overrides
    NumberTextBoxBase.GetNumberValue(String, Int32)

    GetStartPositionJustNumbers(String, Int32)

    Calculates the starting position of numeric characters in the formatted text, adjusting for the presence of a currency symbol.

    Declaration
    protected override int GetStartPositionJustNumbers(string formattedText, int startPosition)
    Parameters
    Type Name Description
    System.String formattedText

    The formatted text to analyze.

    System.Int32 startPosition

    The initial cursor position.

    Returns
    Type
    System.Int32
    Overrides
    NumberTextBoxBase.GetStartPositionJustNumbers(String, Int32)

    GetValue()

    Gets the current decimal value of the CurrencyTextBox.

    Declaration
    protected override object GetValue()
    Returns
    Type
    System.Object
    Overrides
    NumberTextBoxBase.GetValue()

    HandleBackspaceKey()

    Declaration
    protected override bool HandleBackspaceKey()
    Returns
    Type
    System.Boolean
    Overrides
    NumberTextBoxBase.HandleBackspaceKey()

    HandleCharacterKey(Char)

    Handles the insertion of a character key into the text box, adjusting the cursor position if it overlaps with the currency symbol.

    Declaration
    protected override bool HandleCharacterKey(char charToBeInserted)
    Parameters
    Type Name Description
    System.Char charToBeInserted

    The character to be inserted into the text box.

    Returns
    Type
    System.Boolean
    Overrides
    NumberTextBoxBase.HandleCharacterKey(Char)

    HandleDecimalKey()

    Handles the behavior when the decimal key is pressed in the CurrencyTextBox.

    Declaration
    protected override bool HandleDecimalKey()
    Returns
    Type
    System.Boolean
    Overrides
    NumberTextBoxBase.HandleDecimalKey()

    HandleDeleteKey()

    Declaration
    protected override bool HandleDeleteKey()
    Returns
    Type
    System.Boolean
    Overrides
    NumberTextBoxBase.HandleDeleteKey()

    InitializeNumberTextBox()

    Overrides InitializeNumberTextBox().

    Declaration
    protected override void InitializeNumberTextBox()
    Overrides
    NumberTextBoxBase.InitializeNumberTextBox()

    IsAssignable(Object)

    Determines whether the specified object can be assigned as a decimal value.

    Declaration
    protected override bool IsAssignable(object val)
    Parameters
    Type Name Description
    System.Object val

    The object to check.

    Returns
    Type
    System.Boolean
    Overrides
    NumberTextBoxBase.IsAssignable(Object)

    IsDataPosition(String, Int32)

    Determines whether the specified position in the formatted text corresponds to a data (numeric) character.

    Declaration
    protected override bool IsDataPosition(string formattedText, int position)
    Parameters
    Type Name Description
    System.String formattedText

    The formatted text to evaluate.

    System.Int32 position

    The position within the text to check.

    Returns
    Type
    System.Boolean
    Overrides
    NumberTextBoxBase.IsDataPosition(String, Int32)

    IsInDecimalPosition(String, Int32)

    Determines whether the specified cursor position is within the decimal portion of the currency value.

    Declaration
    protected override bool IsInDecimalPosition(string currentText, int startPosition)
    Parameters
    Type Name Description
    System.String currentText

    The current text displayed in the control.

    System.Int32 startPosition

    The cursor position to evaluate.

    Returns
    Type
    System.Boolean
    Overrides
    NumberTextBoxBase.IsInDecimalPosition(String, Int32)

    OnDecimalValueChanged(EventArgs)

    Raises the DecimalValueChanged event.

    Declaration
    protected virtual void OnDecimalValueChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    A System.EventArgs that contains the event data.

    OnEnabledChanged(EventArgs)

    Raises the System.Windows.Forms.Control.EnabledChanged event.

    Declaration
    protected override void OnEnabledChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    An System.EventArgs that contains the event data.

    Overrides
    TextBoxExt.OnEnabledChanged(EventArgs)

    OnEnter(EventArgs)

    Overrides the System.Windows.Forms.Control.OnEnter(System.EventArgs) method.

    Declaration
    protected override void OnEnter(EventArgs args)
    Parameters
    Type Name Description
    System.EventArgs args

    The event data.

    Overrides
    NumberTextBoxBase.OnEnter(EventArgs)
    Remarks

    Saves the current DecimalValue so that it can be compared during validation. The DecimalValueChanged and TextChanged event will only be raised if the value is different during validation.

    OnGotFocus(EventArgs)

    Helps to override the OnGotFocus events

    Declaration
    protected override void OnGotFocus(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    An System.EventArgs that contains the event data.

    Overrides
    TextBoxExt.OnGotFocus(EventArgs)

    OnKeyDown(KeyEventArgs)

    Handles the KeyDown event for the CurrencyTextBox control.

    Declaration
    protected override void OnKeyDown(KeyEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Forms.KeyEventArgs e

    A System.Windows.Forms.KeyEventArgs that contains the event data.

    OnTextChanged(EventArgs)

    Overrides OnTextChanged.

    Declaration
    protected override void OnTextChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The event data.

    Overrides
    NumberTextBoxBase.OnTextChanged(EventArgs)

    OnThemeNameChanged(String)

    Helps to apply the ThemeName settings in control

    Declaration
    public override void OnThemeNameChanged(string themeName)
    Parameters
    Type Name Description
    System.String themeName

    ThemeName

    Overrides
    TextBoxExt.OnThemeNameChanged(String)

    OnValidated(EventArgs)

    Called after the control has been successfully validated. Triggers a custom validation event with the old and new values.

    Declaration
    protected override void OnValidated(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    OnValidating(CancelEventArgs)

    Handles validation logic when the control is losing focus. Ensures the value is within the specified minimum and maximum range, and applies corrective actions if validation fails.

    Declaration
    protected override void OnValidating(CancelEventArgs e)
    Parameters
    Type Name Description
    System.ComponentModel.CancelEventArgs e
    Overrides
    NumberTextBoxBase.OnValidating(CancelEventArgs)

    ParseForNegativeFormat(String, NumberFormatInfo)

    Overrides ParseForNegativeFormat(String, NumberFormatInfo)

    Declaration
    protected override bool ParseForNegativeFormat(string currentText, NumberFormatInfo info)
    Parameters
    Type Name Description
    System.String currentText

    The text to be parsed.

    System.Globalization.NumberFormatInfo info
    Returns
    Type Description
    System.Boolean

    True if the value is negative; false, otherwise

    Overrides
    NumberTextBoxBase.ParseForNegativeFormat(String, NumberFormatInfo)

    PositionCursorAfterEdit(Int32, Boolean, Boolean, Boolean)

    Positions the cursor after an edit operation, adjusting for currency symbols and decimal separators.

    Declaration
    protected override void PositionCursorAfterEdit(int startPositionJustNumbers, bool inDecimalPosition, bool back, bool delete)
    Parameters
    Type Name Description
    System.Int32 startPositionJustNumbers

    The position in the text considering only numeric characters.

    System.Boolean inDecimalPosition

    Indicates whether the cursor is in the decimal portion of the number.

    System.Boolean back

    Indicates whether the edit was a backspace operation.

    System.Boolean delete

    Indicates whether the edit was a delete operation.

    Overrides
    NumberTextBoxBase.PositionCursorAfterEdit(Int32, Boolean, Boolean, Boolean)

    PrepareInsertString(String, Int32, Int32, String, Boolean)

    Prepares the string to be inserted into the text box, adjusting the current text if the decimal value is zero.

    Declaration
    protected override NumberModifyState PrepareInsertString(string currentText, int startPosition, int selectionLength, string textToBeInserted, bool pasteOperation)
    Parameters
    Type Name Description
    System.String currentText

    The current text in the text box.

    System.Int32 startPosition

    The starting position for the insertion.

    System.Int32 selectionLength

    The length of the selected text to be replaced.

    System.String textToBeInserted

    The text to be inserted.

    System.Boolean pasteOperation

    Indicates whether the operation is a paste action.

    Returns
    Type
    NumberModifyState
    Overrides
    NumberTextBoxBase.PrepareInsertString(String, Int32, Int32, String, Boolean)

    RemoveFormatting(String, NumberFormatInfo, Boolean)

    Removes formatting from the specified formatted text, particularly removing the currency symbol if it contains numbers.

    Declaration
    protected override string RemoveFormatting(string formattedText, NumberFormatInfo info, bool padIfEmpty)
    Parameters
    Type Name Description
    System.String formattedText

    The text with formatting to be removed.

    System.Globalization.NumberFormatInfo info

    Number format information used for parsing.

    System.Boolean padIfEmpty

    Indicates whether to pad the result if the formatted text is empty.

    Returns
    Type
    System.String
    Overrides
    NumberTextBoxBase.RemoveFormatting(String, NumberFormatInfo, Boolean)

    ResetCurrencyDecimalDigits()

    Reset the value to the culture specific value.

    Declaration
    protected void ResetCurrencyDecimalDigits()

    ResetCurrencyDecimalSeparator()

    Resets the value to the culture specific value.

    Declaration
    protected void ResetCurrencyDecimalSeparator()

    ResetCurrencyGroupSeparator()

    Resets the value to the culture specific value.

    Declaration
    protected void ResetCurrencyGroupSeparator()

    ResetCurrencyGroupSizes()

    Resets the value to the culture specific value.

    Declaration
    protected void ResetCurrencyGroupSizes()

    ResetCurrencyNegativePattern()

    Resets the value to the culture specific value.

    Declaration
    protected void ResetCurrencyNegativePattern()

    ResetCurrencyNumberDigits()

    Restores the CurrencyNumberDigits to the MaximumLength.

    Declaration
    protected void ResetCurrencyNumberDigits()

    ResetCurrencyPositivePattern()

    Resets the value to the culture specific value.

    Declaration
    protected void ResetCurrencyPositivePattern()

    ResetCurrencySymbol()

    Resets the value to the culture specific value

    Declaration
    protected void ResetCurrencySymbol()

    ResetMaxValue()

    Resets the value to the default.

    Declaration
    protected void ResetMaxValue()

    ResetMinValue()

    Resets the value to the default.

    Declaration
    protected void ResetMinValue()

    ResetNumberDigits()

    Restores the CurrencyNumberDigits to the MaximumLength.

    Declaration
    protected void ResetNumberDigits()

    ResetText()

    Restores the CurrencyNumberDigits to the MaximumLength.

    Declaration
    protected void ResetText()

    SetDecimalValue(Decimal)

    Sets the decimal value of the CurrencyTextBox and updates the control's text accordingly.

    Declaration
    protected void SetDecimalValue(decimal newValue)
    Parameters
    Type Name Description
    System.Decimal newValue

    The new decimal value to be set.

    SetNullNumberValue()

    Sets the internal decimal value to zero when the control is in a null state.

    Declaration
    protected override void SetNullNumberValue()
    Overrides
    NumberTextBoxBase.SetNullNumberValue()

    SetTextProperty(String)

    Sets the text property of the CurrencyTextBox control, parsing and formatting the input as needed.

    Declaration
    protected override void SetTextProperty(string newText)
    Parameters
    Type Name Description
    System.String newText

    The new text value to be set in the control.

    Overrides
    NumberTextBoxBase.SetTextProperty(String)

    SetValue(Object)

    Sets the value of the CurrencyTextBox using the specified object.

    Declaration
    protected override void SetValue(object val)
    Parameters
    Type Name Description
    System.Object val

    The object to be converted and assigned as a decimal value.

    Overrides
    NumberTextBoxBase.SetValue(Object)

    ShouldSerializeCurrencyDecimalDigits()

    Indicates whether the CurrencyDecimalDigits should not be serialized if the value is the same as the one for the current culture.

    Declaration
    protected bool ShouldSerializeCurrencyDecimalDigits()
    Returns
    Type Description
    System.Boolean

    True if the value is different from the value for the current culture.

    ShouldSerializeCurrencyDecimalSeparator()

    Indicates whether the CurrencyDecimalSeparator should not be serialized if the value is the same as the one for the current culture.

    Declaration
    protected bool ShouldSerializeCurrencyDecimalSeparator()
    Returns
    Type Description
    System.Boolean

    True if the value is different from the value for the current culture.

    ShouldSerializeCurrencyGroupSeparator()

    Indicates whether the CurrencyGroupSeparator should not be serialized if the value is the same as the one for the current culture.

    Declaration
    protected bool ShouldSerializeCurrencyGroupSeparator()
    Returns
    Type Description
    System.Boolean

    True if the value is different from the value for the current culture.

    ShouldSerializeCurrencyGroupSizes()

    Indicates whether the CurrencyGroupSizes should not be serialized if the value is the same as the one for the current culture.

    Declaration
    protected bool ShouldSerializeCurrencyGroupSizes()
    Returns
    Type Description
    System.Boolean

    True if the value is different from the value for the current culture.

    ShouldSerializeCurrencyNegativePattern()

    Indicates whether the CurrencyNegativePattern should not be serialized if the value is the same as the one for the current culture.

    Declaration
    protected bool ShouldSerializeCurrencyNegativePattern()
    Returns
    Type Description
    System.Boolean

    True if the value is different from the value for the current culture.

    ShouldSerializeCurrencyNumberDigits()

    Indicates whether to serialize the CurrencyNumberDigits property if its the same as the MaximumLength

    Declaration
    protected bool ShouldSerializeCurrencyNumberDigits()
    Returns
    Type
    System.Boolean

    ShouldSerializeCurrencyPositivePattern()

    Indicates whether the CurrencyPositivePattern should not be serialized if the value is the same as the one for the current culture.

    Declaration
    protected bool ShouldSerializeCurrencyPositivePattern()
    Returns
    Type Description
    System.Boolean

    True if the value is different from the value for the current culture.

    ShouldSerializeCurrencySymbol()

    Indicates whether the CurrencySymbol should not be serialized if the value is the same as the one for the current culture.

    Declaration
    protected bool ShouldSerializeCurrencySymbol()
    Returns
    Type Description
    System.Boolean

    True if the value is different from the value for the current culture.

    ShouldSerializeMaxValue()

    Indicates whether the MaxValue property should be serialized.

    Declaration
    protected bool ShouldSerializeMaxValue()
    Returns
    Type Description
    System.Boolean

    true if the value is not equal to System.Decimal.MaxValue

    ShouldSerializeMinValue()

    Indicates whether the MinValue property should be serialized.

    Declaration
    protected bool ShouldSerializeMinValue()
    Returns
    Type Description
    System.Boolean

    True if the value is not equal to System.Decimal.MaxValue

    ShouldSerializeNumberDigits()

    Indicates whether to serialize the CurrencyNumberDigits property if its the same as the MaximumLength.

    Declaration
    protected bool ShouldSerializeNumberDigits()
    Returns
    Type
    System.Boolean

    ShouldSerializeText()

    Indicates whether to serialize the Text property if it is null or quals NullString

    Declaration
    protected bool ShouldSerializeText()
    Returns
    Type
    System.Boolean

    ToggleNegative(String)

    Toggles the sign of the numeric value represented by the current text.

    Declaration
    protected override string ToggleNegative(string currentText)
    Parameters
    Type Name Description
    System.String currentText

    The current text representing a numeric value.

    Returns
    Type
    System.String
    Overrides
    NumberTextBoxBase.ToggleNegative(String)

    Events

    DecimalValueChanged

    Occurs when the DecimalValue property is changed.

    Declaration
    public event EventHandler DecimalValueChanged
    Event Type
    Type
    System.EventHandler

    Implements

    IThemeProvider
    IVisualStyle
    System.ComponentModel.ISupportInitialize
    System.Runtime.Serialization.ISerializable
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved