DecimalTextBox Class

Represents a text box to edit decimal values.

Definition

Namespace: KGySoft.WinForms.Controls
Assembly: KGySoft.WinForms (in KGySoft.WinForms.dll) Version: 5.0.1
C#
[ToolboxBitmapAttribute(typeof(DecimalTextBox), "Resources.Toolbox.DecimalTextBox.png")]
public class DecimalTextBox : AdvancedTextBox
Inheritance
Object    MarshalByRefObject    Component    Control    TextBoxBase    TextBox    AdvancedTextBox    DecimalTextBox

Remarks

The DecimalTextBox control offers the following features:
  • Coloring in disabled mode (provided by the base AdvancedTextBox control).
  • A decimal Value property for getting/setting the decimal value.
  • Multiplier hotkeys: t = thousand; m = million; y = billion (yard).
  • Configurable limits for Value.
  • Optional blank state if BlankEnabled is .
  • Formatting options (see Format).
  • Configurable number of decimal digits or rounding (see DecimalDigits).

  Tip

See also the example application that contains an example for some features of the AdvancedButton control.
The example is located under the Controls Tests / AdvancedTextBox menu.

Constructors

DecimalTextBox Creates a new instance of DecimalTextBox control.

Properties

AutoCompleteModeGets or sets an option that controls how automatic completion works for the TextBox.
(Inherited from AdvancedTextBox)
AutoScaleFont Gets or sets whether the Font should be automatically scaled when DPI changes and the current thread has per-monitor DPI awareness.
Default value: .
(Inherited from AdvancedTextBox)
BackColor Gets or sets the background color of the control in the current Enabled and ReadOnly state.
(Inherited from AdvancedTextBox)
Blank Gets or sets whether the DecimalTextBox is in blank state. Can be set only if BlankEnabled is .
Default value: .
BlankEnabled Gets or sets whether Blank state can be enabled. When , then the DecimalTextBox will be automatically blank if Value is out of range.
Default value: .
BlankText Gets or sets the caption in Blank state.
Default value: Empty string.
ChangeValueOnTextChange Gets or sets whether Value should be changed for every keystroke when the text is edited.
Default value: , meaning, Value changes only when the control is left.
DecimalDigits Gets or sets the used fraction digits. When negative, Value is rounded to the number of specified digits.
Default value: 0.
DisabledBackColor Gets or sets the background color when the control is not Enabled or is ReadOnly.
(Inherited from AdvancedTextBox)
DisabledForeColor Gets or sets the text color when the control is not Enabled.
(Inherited from AdvancedTextBox)
EnabledBackColor Gets or sets the background color when the control is Enabled and not ReadOnly.
(Inherited from AdvancedTextBox)
EnabledForeColor Gets or sets the text color when the control is Enabled.
(Inherited from AdvancedTextBox)
FontGets or sets the font of the text displayed by the control.
(Inherited from AdvancedTextBox)
ForeColor Gets or sets the foreground color of the control in the current state.
(Inherited from AdvancedTextBox)
Format Gets or sets the numeric formatting of the displayed Value.
Default value: Number.
Range Gets or sets the valid range for the Value property. If Value violates the newly set range, then either Blank will be set, or Value will be corrected if BlankEnabled is .
RangeMaxValue Gets or sets the accepted maximum Value. If Value violates the newly set maximum value, then either Blank will be set, or Value will be corrected if BlankEnabled is .
RangeMinValue Gets or sets the accepted minimum Value. If Value violates the newly set minimum value, then either Blank will be set, or Value will be corrected if BlankEnabled is .
Text Gets or sets the text of the DecimalTextBox. It is recommended to use the Value property instead.
(Overrides TextBoxText)
TextAlign Gets or sets the horizontal text alignment.
Default value: Right.
Value Gets or sets the value of the DecimalTextBox.
Default value: 0.
ValueOnBlank Gets or sets what the Value property should return in Blank state.
Default value: Zero.

Methods

DisposeReleases the unmanaged resources used by the TextBox and optionally releases the managed resources.
(Inherited from AdvancedTextBox)
IsInputKeyDetermines whether the specified key is an input key or a special key that requires preprocessing.
(Inherited from AdvancedTextBox)
OnBlankChanged Raises the BlankChanged event.
OnEnabledChangedRaises the EnabledChanged event.
(Inherited from AdvancedTextBox)
OnEnterRaises the Enter event.
(Overrides AdvancedTextBoxOnEnter(EventArgs))
OnFontChangedRaises the FontChanged event.
(Inherited from AdvancedTextBox)
OnHandleCreatedRaises the HandleCreated event.
(Inherited from AdvancedTextBox)
OnKeyDownRaises the KeyDown event.
(Overrides ControlOnKeyDown(KeyEventArgs))
OnKeyPressRaises the KeyPress event.
(Overrides ControlOnKeyPress(KeyPressEventArgs))
OnLeaveRaises the Leave event.
(Overrides AdvancedTextBoxOnLeave(EventArgs))
OnPaintRaises the Paint event.
(Inherited from AdvancedTextBox)
OnParentChangedRaises the ParentChanged event.
(Inherited from AdvancedTextBox)
OnParentFontChangedRaises the FontChanged event when the Font property value of the control's container changes.
(Inherited from AdvancedTextBox)
OnReadOnlyChangedRaises the ReadOnlyChanged event.
(Inherited from AdvancedTextBox)
OnRightToLeftChangedRaises the RightToLeftChanged event.
(Inherited from AdvancedTextBox)
OnTextChangedRaises the TextChanged event.
(Overrides TextBoxBaseOnTextChanged(EventArgs))
OnTextChangedOnLeave Raises the TextChangedOnLeave event.
(Inherited from AdvancedTextBox)
OnValidatingRaises the Validating event.
(Overrides ControlOnValidating(CancelEventArgs))
OnValueChanged Raises the ValueChanged event.
ProcessCmdKeyProcesses a command key.
(Inherited from AdvancedTextBox)
WndProcProcesses Windows messages.
(Overrides AdvancedTextBoxWndProc(Message))

Events

BlankChanged Occurs when the Blank property has changed.
TextChangedOnLeave Occurs on leaving the control when Text is different from the value when the control received focus. It is raised after the Leave and before the Validating event.
(Inherited from AdvancedTextBox)
ValueChanged Occurs when the Value property has changed.

Extension Methods

GetFormatFlags Gets the formatting flags for the text of a custom drawn control.
(Defined by ControlExtensions)
GetScale Gets the current scale factor of the specified control. If per-monitor DPI awareness is not enabled, it always returns SystemScale.
(Defined by ScaleHelper)
GetScrollBarSize Gets the recommended width and height of scrollbars matching the current scaling of the specified control.
(Defined by ScaleHelper)
HasDefaultScaling Gets whether the display that the specified control belongs to has the same DPI as the initial DPI of the primary display.
(Defined by ScaleHelper)
ScaleHeight Scales the specified height by the vertical scale factor of the control.
(Defined by ScaleHelper)
ScaleSize Scales the specified size by the scale factor of the control.
(Defined by ScaleHelper)
ScaleWidth Scales the specified width by the horizontal scale factor of the control.
(Defined by ScaleHelper)
SetControlEnabled Sets the Enabled property of the child controls within the specified root control, or the Enabled property of the specified control itself, if it is not a recognized container control. By this way pages of a TabControl will remain selectable, a SplitContainer remains resizable, etc.
(Defined by ControlExtensions)
SetControlReadonly Recursively sets the read-only state in the children of the specified root control. Affects TextBoxBase and IReadOnlyCapable instances.
(Defined by ControlExtensions)
SetDoubleBuffered Sets the double buffered state of a control
(Defined by ControlExtensions)
SetStyle Sets a specified ControlStyles flag to either or . It calls the protected Control.SetStyle method on the specified control as if it was a public method.
(Defined by ControlExtensions)

See Also