Class RadSpinElement
Represents a numeric up/down element that provides spinning functionality for numeric value input. The RadSpinElement class is a simple wrapper for the numeric up/down element class. The RadSpinElement acts to transfer events to and from its corresponding numeric up/down element instance. The numeric up/down element which is essentially the RadSpinElement control may be nested in other telerik controls.
Inheritance
Inherited Members
Namespace: Telerik.WinControls.UI
Assembly: Telerik.WinControls.UI.dll
Syntax
public class RadSpinElement : RadEditorElement, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IComponent, IDisposable, IBindableComponent, ISupportDrag, ISupportDrop, IShortcutProvider, IStylableElement, IStylableNode
Constructors
RadSpinElement()
Declaration
public RadSpinElement()
Fields
internalValue
Declaration
protected decimal internalValue
Field Value
System.Decimal
|
NullableValueChanged
Occurs when the nullable value has changed.
Declaration
public EventHandler NullableValueChanged
Field Value
System.EventHandler
|
Properties
ButtonDown
Gets a reference to the down button element used for decrementing the value.
Declaration
public RadRepeatArrowElement ButtonDown { get; }
Property Value
RadRepeatArrowElement
|
ButtonsLayout
Gets the layout element that contains the increment and decrement buttons.
Declaration
protected StackLayoutElement ButtonsLayout { get; }
Property Value
StackLayoutElement
|
ButtonUp
Gets a reference to the up button element used for incrementing the value.
Declaration
public RadRepeatArrowElement ButtonUp { get; }
Property Value
RadRepeatArrowElement
|
DecimalPlaces
Gets or sets the number of decimal places to display in the spin element.
Declaration
public int DecimalPlaces { get; set; }
Property Value
System.Int32
|
DefaultValue
Gets or sets the default value for the numeric up/down element.
Declaration
protected decimal DefaultValue { get; set; }
Property Value
System.Decimal
|
EnableMouseWheel
Gets or sets a value indicating whether the user can change the value using the mouse wheel.
Declaration
public bool EnableMouseWheel { get; set; }
Property Value
System.Boolean
|
EnableNullValueInput
Gets or sets a value indicating whether empty text in the editor should be interpreted as a null value. When true, an empty text box will result in a null NullableValue.
Declaration
public virtual bool EnableNullValueInput { get; set; }
Property Value
System.Boolean
|
Hexadecimal
Gets or sets a value indicating whether the RadSpinEdit should display the value it contains in hexadecimal format.
Declaration
public bool Hexadecimal { get; set; }
Property Value
System.Boolean
|
InterceptArrowKeys
Gets or sets a value indicating whether the user can use the UP ARROW and DOWN ARROW keys to change values.
Declaration
public bool InterceptArrowKeys { get; set; }
Property Value
System.Boolean
|
Layout
Gets the main layout element that arranges the text box and buttons.
Declaration
protected StackLayoutElement Layout { get; }
Property Value
StackLayoutElement
|
MaxValue
Gets or sets the maximum value that can be entered in the spin element.
Declaration
public decimal MaxValue { get; set; }
Property Value
System.Decimal
|
MinValue
Gets or sets the minimum value that can be entered in the spin element.
Declaration
public decimal MinValue { get; set; }
Property Value
System.Decimal
|
NullableValue
Gets or sets the nullable decimal value in the numeric up/down element. This value can be null when EnableNullValueInput is true.
Declaration
public virtual decimal? NullableValue { get; set; }
Property Value
System.Nullable<System.Decimal>
|
ReadOnly
Gets or sets a value indicating whether the text can be changed by the use of the up or down buttons only. When true, direct text input is disabled.
Declaration
public bool ReadOnly { get; set; }
Property Value
System.Boolean
|
RightMouseButtonReset
Gets or sets a value indicating whether right-clicking the up/down buttons resets the value to maximum/minimum respectively.
Declaration
public bool RightMouseButtonReset { get; set; }
Property Value
System.Boolean
|
ShowBorder
Gets or sets a value indicating whether the border around the spin element is visible.
Declaration
public bool ShowBorder { get; set; }
Property Value
System.Boolean
|
ShowUpDownButtons
Gets or sets a value indicating whether the up/down buttons are visible and functional. When false, the spin element acts as a numeric text box without increment/decrement buttons.
Declaration
public bool ShowUpDownButtons { get; set; }
Property Value
System.Boolean
|
Step
Gets or sets the value that is added to or subtracted from the current value when incrementing or decrementing.
Declaration
public decimal Step { get; set; }
Property Value
System.Decimal
|
StretchVertically
Gets or sets a value indicating whether the element should be stretched vertically to fill available space.
Declaration
public override bool StretchVertically { get; set; }
Property Value
System.Boolean
|
Overrides
Text
Gets or sets the text content of the spin element.
Declaration
public override string Text { get; set; }
Property Value
System.String
|
Overrides
TextAlignment
Gets or sets the minimum value that could be set in the spin editor
Declaration
public virtual HorizontalAlignment TextAlignment { get; set; }
Property Value
System.Windows.Forms.HorizontalAlignment
|
TextBoxControl
Gets the underlying text box control used for input.
Declaration
public TextBox TextBoxControl { get; }
Property Value
System.Windows.Forms.TextBox
|
TextBoxItem
Gets RadTextBoxItem contained in the spin editor.
Declaration
public virtual RadTextBoxItem TextBoxItem { get; }
Property Value
RadTextBoxItem
|
ThousandsSeparator
Gets or sets a value indicating whether a thousands separator is displayed in the RadSpinEdit
Declaration
public bool ThousandsSeparator { get; set; }
Property Value
System.Boolean
|
Value
Gets or sets the current decimal value of the spin element.
Declaration
public decimal Value { get; set; }
Property Value
System.Decimal
|
Wrap
Gets or sets a value indicating whether the value wraps around when reaching minimum or maximum limits. When true, exceeding the maximum value wraps to minimum and vice versa.
Declaration
public bool Wrap { get; set; }
Property Value
System.Boolean
|
Methods
Constrain(Decimal)
Constrains the specified value to be within the minimum and maximum range, applying wrap-around logic if enabled.
Declaration
protected virtual decimal Constrain(decimal value)
Parameters
System.Decimal
value
The value to constrain. |
Returns
System.Decimal
The constrained value within the valid range. |
CreateChildElements()
Creates the child elements that compose the RadSpinElement including text box, buttons, and layout containers.
Declaration
protected override void CreateChildElements()
Overrides
CreateDownButton()
Creates the button element for decrementing the value.
Declaration
protected virtual RadRepeatArrowElement CreateDownButton()
Returns
RadRepeatArrowElement
A RadRepeatArrowElement configured as a down button. |
CreateUpButton()
Creates the button element for incrementing the value.
Declaration
protected virtual RadRepeatArrowElement CreateUpButton()
Returns
RadRepeatArrowElement
A RadRepeatArrowElement configured as an up button. |
DisposeManagedResources()
Disposes of managed resources and unbinds properties.
Declaration
protected override void DisposeManagedResources()
Overrides
EndTextEdit()
Ends the current text editing session and validates the input.
Declaration
protected virtual void EndTextEdit()
GetNumberText(Decimal)
Gets the formatted number text representation of the specified value.
Declaration
protected virtual string GetNumberText(decimal num)
Parameters
System.Decimal
num
The numeric value to format. |
Returns
System.String
The formatted string representation of the number. |
GetValueFromText()
Parses the current text content and returns the corresponding decimal value.
Declaration
protected virtual decimal GetValueFromText()
Returns
System.Decimal
The decimal value parsed from the text, or the current internal value if parsing fails. |
InitializeButtons()
Initializes the up and down arrow buttons and their container layout.
Declaration
protected virtual void InitializeButtons()
InitializeFields()
Initializes the default field values for the spin element.
Declaration
protected override void InitializeFields()
Overrides
MeasureOverride(SizeF)
Measures the desired size of the element within the specified available size.
Declaration
protected override SizeF MeasureOverride(SizeF availableSize)
Parameters
System.Drawing.SizeF
availableSize
The available size that this element can be given. |
Returns
System.Drawing.SizeF
The desired size of this element. |
Overrides
OnBitStateChanged(Int64, Boolean, Boolean)
Handles changes to bit state flags and updates the UI accordingly.
Declaration
protected override void OnBitStateChanged(long key, bool oldValue, bool newValue)
Parameters
System.Int64
key
The bit state key that changed. |
System.Boolean
oldValue
The previous value. |
System.Boolean
newValue
The new value. |
Overrides
OnKeyDown(KeyEventArgs)
Handles key down events and processes arrow keys for value increment/decrement if enabled.
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
System.Windows.Forms.KeyEventArgs
e
A System.Windows.Forms.KeyEventArgs that contains the event data. |
Overrides
OnKeyPress(KeyPressEventArgs)
Handles key press events and performs validation for the current key press.
Declaration
protected override void OnKeyPress(KeyPressEventArgs e)
Parameters
System.Windows.Forms.KeyPressEventArgs
e
A System.Windows.Forms.KeyPressEventArgs that contains the event data. |
Overrides
OnNullableValueChanged()
OnPropertyChanged(RadPropertyChangedEventArgs)
Handles property change notifications and updates related elements.
Declaration
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
Parameters
RadPropertyChangedEventArgs
e
A RadPropertyChangedEventArgs that contains the event data. |
Overrides
OnTextBoxKeyPress(KeyPressEventArgs)
Handles key press events for the text box, filtering valid numeric input based on current format settings.
Declaration
protected void OnTextBoxKeyPress(KeyPressEventArgs e)
Parameters
System.Windows.Forms.KeyPressEventArgs
e
A System.Windows.Forms.KeyPressEventArgs that contains the event data. |
OnTextChanged(EventArgs)
Raises the TextChanged event.
Declaration
protected override void OnTextChanged(EventArgs e)
Parameters
System.EventArgs
e
An System.EventArgs that contains the event data. |
Overrides
OnValueChanged(EventArgs)
Raises the ValueChanged event.
Declaration
protected virtual void OnValueChanged(EventArgs e)
Parameters
System.EventArgs
e
An System.EventArgs that contains the event data. |
OnValueChanging(ValueChangingEventArgs)
Raises the ValueChanging event.
Declaration
protected virtual void OnValueChanging(ValueChangingEventArgs e)
Parameters
ValueChangingEventArgs
e
A ValueChangingEventArgs that contains the event data. |
PerformStep(Decimal)
Increments or decrements the current value by the specified step amount.
Declaration
public virtual void PerformStep(decimal step)
Parameters
System.Decimal
step
The amount to add to or subtract from the current value. |
ProcessMouseWheel(MouseEventArgs)
Processes mouse wheel events and forwards them to the parent control.
Declaration
protected virtual void ProcessMouseWheel(MouseEventArgs e)
Parameters
System.Windows.Forms.MouseEventArgs
e
A System.Windows.Forms.MouseEventArgs that contains the event data. |
SetSpinValue(Decimal, Boolean)
Sets the internal value of the spin element and updates the display.
Declaration
protected virtual void SetSpinValue(decimal value, bool fromValue)
Parameters
System.Decimal
value
The value to set. |
System.Boolean
fromValue
Indicates whether the change originates from the Value property. |
SetSuppresEditorState(Boolean)
This method is used internally!
Declaration
public void SetSuppresEditorState(bool newState)
Parameters
System.Boolean
newState
The new flag state. |
SetTextValueChanged(Boolean)
This method is used internally!
Declaration
public void SetTextValueChanged(bool newState)
Parameters
System.Boolean
newState
The new flag state. |
textItem_GotFocus(Object, EventArgs)
Handles the focus gained event for the text item and updates the focus border.
Declaration
protected virtual void textItem_GotFocus(object sender, EventArgs e)
Parameters
System.Object
sender
The source of the event. |
System.EventArgs
e
An System.EventArgs that contains the event data. |
textItem_LostFocus(Object, EventArgs)
Handles the focus lost event for the text item and updates the focus border.
Declaration
protected virtual void textItem_LostFocus(object sender, EventArgs e)
Parameters
System.Object
sender
The source of the event. |
System.EventArgs
e
An System.EventArgs that contains the event data. |
UnwireButtonEvents()
Detaches event handlers from the increment and decrement buttons.
Declaration
protected void UnwireButtonEvents()
UnwireEvents()
Detaches event handlers from the text box and other child elements.
Declaration
protected virtual void UnwireEvents()
Validate()
Validates the current value and updates the display if necessary.
Declaration
public virtual bool Validate()
Returns
System.Boolean
True if validation succeeded, false otherwise. |
ValidateCore()
Performs core validation logic for the current internal value.
Declaration
protected virtual void ValidateCore()
ValidateOnKeyPress(KeyPressEventArgs)
Validates the input on key press and handles Enter key for value validation.
Declaration
protected virtual void ValidateOnKeyPress(KeyPressEventArgs e)
Parameters
System.Windows.Forms.KeyPressEventArgs
e
A System.Windows.Forms.KeyPressEventArgs that contains the event data. |
WireButtonEvents()
Attaches event handlers to the increment and decrement buttons.
Declaration
protected void WireButtonEvents()
WireEvents()
Attaches event handlers to the text box and other child elements.
Declaration
protected virtual void WireEvents()
Events
KeyDown
Occurs when the user presses a key while the spin element has focus.
Declaration
public event KeyEventHandler KeyDown
Event Type
System.Windows.Forms.KeyEventHandler
|
ValueChanged
Occurs before the value of the spin element has changed.
Declaration
public event EventHandler ValueChanged
Event Type
System.EventHandler
|
ValueChanging
Occurs when the value is being changed. This is a cancelable event.
Declaration
public event ValueChangingEventHandler ValueChanging
Event Type
ValueChangingEventHandler
|