HypernovaDesktop Components · docs
Binarymission
WinForms › Extended Text › BinaryNumericExtendedText

BinaryNumericExtendedText

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.TextControls

A class derived from <seealso cref="BinaryExtendedText"/> that allows only numeric input or numeric input within a specified numeric range.

public class BinaryNumericExtendedText : BinaryExtendedText, ISupportInitialize

Inherits from / implements: BinaryExtendedText, ISupportInitialize

Remarks

The text is the value. There is no separate editing buffer: what the user types is checked as it arrives, clamped to the range while it is typed, and read back through Value as a number. Three things are worth knowing before changing any of it. Decimals are off until DecimalPlaces says otherwise, and the separator accepted is the current culture's, not a full stop. Stepping - the arrow keys, page keys and the wheel - moves by Step and is switched by EnableStepping. And the grouping separators are added when the control loses the focus and taken out again when it regains it, so the user never edits around them.

Members at a glance

BinaryNumericExtendedTextCreates a new instance of the BinaryNumericExtendedText .NET control.
DecimalPlacesGets or sets how many decimal places the box accepts and shows. Zero, the default, is whole numbers only and no decimal separator is accepted.
EnableSteppingGets or sets whether the arrow keys, the page keys and the wheel step the value.
MaximumGets or sets the maximum numeric value that can be set when using input range.
MinimumGets or sets the minimum numeric value that can be set when using input range.
SelectAllOnFocusGets or sets whether the text is selected when the box takes the focus, so that typing replaces the value rather than adding to it.
ShouldIUseInputRangeGets or sets as to whether an input range is to be used or not.
ShowThousandsSeparatorGets or sets whether the value is shown with the culture's grouping separators while the box does not have the focus.
StepGets or sets how much the arrow keys, the page keys and the wheel move the value.
TextGets or sets the Numeric text. Setting non-numeric text is not allowed!
ValueGets or sets the value as a number, or null when the box is empty.
BeginInitImplementation of ISupportInitialize.BeginInit.
EndInitImplementation of ISupportInitialize.EndInit.
OnEnterRaises the Enter event. The grouping separators come out for editing, and the text is selected when the control is asked to.
OnKeyDownRaises the KeyDown event. Up, down, page up and page down step the value.
OnKeyPressRaises the KeyPress event. BinaryNumericExtendedText overrides it so the control's own handling runs alongside the base behavior.
OnLostFocusRaises the LostFocus event. BinaryNumericExtendedText overrides it so the control's own handling runs alongside the base behavior.
OnMouseWheelRaises the MouseWheel event. A notch steps the value while the box has the focus.
OnValueChangedRaises the ValueChanged event.
StepByMoves the value by one step, within the range when one is in force.
ValueChangedRaised when the numeric value changes, however it was changed - typed, stepped, or assigned.

Constructors

BinaryNumericExtendedText

public BinaryNumericExtendedText()

Creates a new instance of the BinaryNumericExtendedText .NET control.

Properties

DecimalPlaces

public int DecimalPlaces

Gets or sets how many decimal places the box accepts and shows. Zero, the default, is whole numbers only and no decimal separator is accepted.

EnableStepping

public bool EnableStepping

Gets or sets whether the arrow keys, the page keys and the wheel step the value.

Maximum

public int Maximum

Gets or sets the maximum numeric value that can be set when using input range.

Minimum

public int Minimum

Gets or sets the minimum numeric value that can be set when using input range.

SelectAllOnFocus

public bool SelectAllOnFocus

Gets or sets whether the text is selected when the box takes the focus, so that typing replaces the value rather than adding to it.

ShouldIUseInputRange

public bool ShouldIUseInputRange

Gets or sets as to whether an input range is to be used or not.

ShowThousandsSeparator

public bool ShowThousandsSeparator

Gets or sets whether the value is shown with the culture's grouping separators while the box does not have the focus.

Only while it does not have the focus: separators inserted under a caret are a well-known way to make a number box unusable.

Step

public decimal Step

Gets or sets how much the arrow keys, the page keys and the wheel move the value.

Text

public override string Text

Gets or sets the Numeric text. Setting non-numeric text is not allowed!

Value

public decimal? Value

Gets or sets the value as a number, or null when the box is empty.

Reading it parses what is in the box, so it answers with the grouping separators and the decimal places taken account of; writing it formats the number the way the box is set to show it, and clamps it to the range when one is in force.

Methods

BeginInit

public void BeginInit()

Implementation of ISupportInitialize.BeginInit.

EndInit

public void EndInit()

Implementation of ISupportInitialize.EndInit.

OnEnter

protected override void OnEnter(EventArgs e)

Raises the Enter event. The grouping separators come out for editing, and the text is selected when the control is asked to.

e
The data for the event.

OnKeyDown

protected override void OnKeyDown(KeyEventArgs e)

Raises the KeyDown event. Up, down, page up and page down step the value.

e
The data for the event.

OnKeyPress

protected override void OnKeyPress(KeyPressEventArgs e)

Raises the KeyPress event. BinaryNumericExtendedText overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

OnLostFocus

protected override void OnLostFocus(EventArgs e)

Raises the LostFocus event. BinaryNumericExtendedText overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

OnMouseWheel

protected override void OnMouseWheel(MouseEventArgs e)

Raises the MouseWheel event. A notch steps the value while the box has the focus.

e
The data for the event.

OnValueChanged

protected virtual void OnValueChanged(EventArgs e)

Raises the ValueChanged event.

e
The data for the event.

StepBy

public void StepBy(decimal by)

Moves the value by one step, within the range when one is in force.

by
How far to move it, positive or negative.

Events

ValueChanged

public event EventHandler ValueChanged

Raised when the numeric value changes, however it was changed - typed, stepped, or assigned.