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.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.UI.dll
Syntax:
public class RadSpinElement : RadEditorElement, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IBindableComponent, IComponent, IDisposable, ISupportDrag, ISupportDrop, IShortcutProvider, IStylableElement, IStylableNode
Inheritance: objectDisposableObjectRadObjectRadElementVisualElementRadComponentElementRadItemRadEditorElementRadSpinElement...
Derived Classes:
Implements:
Inherited Members
Constructors
public RadSpinElement()
Fields
protected decimal internalValue
Occurs when the nullable value has changed.
public EventHandler NullableValueChanged
Properties
Gets a reference to the down button element used for decrementing the value.
[Browsable(false)]
public RadRepeatArrowElement ButtonDown { get; }
Gets the layout element that contains the increment and decrement buttons.
protected StackLayoutElement ButtonsLayout { get; }
Gets a reference to the up button element used for incrementing the value.
[Browsable(false)]
public RadRepeatArrowElement ButtonUp { get; }
Gets or sets the number of decimal places to display in the spin element.
public int DecimalPlaces { get; set; }
Gets or sets the default value for the numeric up/down element.
protected decimal DefaultValue { get; set; }
Gets or sets a value indicating whether the user can change the value using the mouse wheel.
[Browsable(false)]
public bool EnableMouseWheel { get; set; }
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.
[Browsable(false)]
public virtual bool EnableNullValueInput { get; set; }
Gets or sets a value indicating whether the RadSpinEdit should display the value it contains in hexadecimal format.
public bool Hexadecimal { get; set; }
Gets or sets a value indicating whether the user can use the UP ARROW and DOWN ARROW keys to change values.
public bool InterceptArrowKeys { get; set; }
Gets the main layout element that arranges the text box and buttons.
protected StackLayoutElement Layout { get; }
Gets or sets the maximum value that can be entered in the spin element.
public decimal MaxValue { get; set; }
Gets or sets the minimum value that can be entered in the spin element.
public decimal MinValue { get; set; }
Gets or sets the nullable decimal value in the numeric up/down element. This value can be null when EnableNullValueInput is true.
[Browsable(false)]
public virtual decimal? NullableValue { get; set; }
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.
public bool ReadOnly { get; set; }
Gets or sets a value indicating whether right-clicking the up/down buttons resets the value to maximum/minimum respectively.
public bool RightMouseButtonReset { get; set; }
Gets or sets a value indicating whether the border around the spin element is visible.
[Browsable(true)]
public bool ShowBorder { get; set; }
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.
public bool ShowUpDownButtons { get; set; }
Gets or sets the value that is added to or subtracted from the current value when incrementing or decrementing.
public decimal Step { get; set; }
Gets or sets a value indicating whether the element should be stretched vertically to fill available space.
public override bool StretchVertically { get; set; }
Overrides:
Gets or sets the text content of the spin element.
public override string Text { get; set; }
Overrides:
Gets or sets the minimum value that could be set in the spin editor
public virtual HorizontalAlignment TextAlignment { get; set; }
Gets the underlying text box control used for input.
public TextBox TextBoxControl { get; }
TextBoxItem
RadTextBoxItem
Gets RadTextBoxItem contained in the spin editor.
public virtual RadTextBoxItem TextBoxItem { get; }
Gets or sets a value indicating whether a thousands separator is displayed in the RadSpinEdit
public bool ThousandsSeparator { get; set; }
Gets or sets the current decimal value of the spin element.
public decimal Value { get; set; }
Methods
Creates the child elements that compose the RadSpinElement including text box, buttons, and layout containers.
protected override void CreateChildElements()
Overrides:
Creates the button element for decrementing the value.
protected virtual RadRepeatArrowElement CreateDownButton()
A RadRepeatArrowElement configured as a down button.
Creates the button element for incrementing the value.
protected virtual RadRepeatArrowElement CreateUpButton()
A RadRepeatArrowElement configured as an up button.
Disposes of managed resources and unbinds properties.
protected override void DisposeManagedResources()
Overrides:
Ends the current text editing session and validates the input.
protected virtual void EndTextEdit()
Parses the current text content and returns the corresponding decimal value.
protected virtual decimal GetValueFromText()
The decimal value parsed from the text, or the current internal value if parsing fails.
Initializes the up and down arrow buttons and their container layout.
protected virtual void InitializeButtons()
Initializes the default field values for the spin element.
protected override void InitializeFields()
Overrides:
Handles key down events and processes arrow keys for value increment/decrement if enabled.
protected override void OnKeyDown(KeyEventArgs e)
A KeyEventArgs that contains the event data.
Overrides:
Handles key press events and performs validation for the current key press.
protected override void OnKeyPress(KeyPressEventArgs e)
A KeyPressEventArgs that contains the event data.
Overrides:
Raises the NullableValueChanged event.
protected virtual void OnNullableValueChanged()
Handles property change notifications and updates related elements.
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
A RadPropertyChangedEventArgs that contains the event data.
Overrides:
Handles key press events for the text box, filtering valid numeric input based on current format settings.
protected void OnTextBoxKeyPress(KeyPressEventArgs e)
A KeyPressEventArgs that contains the event data.
Raises the ValueChanged event.
Raises the ValueChanging event.
protected virtual void OnValueChanging(ValueChangingEventArgs e)
A ValueChangingEventArgs that contains the event data.
Increments or decrements the current value by the specified step amount.
public virtual void PerformStep(decimal step)
The amount to add to or subtract from the current value.
Processes mouse wheel events and forwards them to the parent control.
protected virtual void ProcessMouseWheel(MouseEventArgs e)
A MouseEventArgs that contains the event data.
Detaches event handlers from the increment and decrement buttons.
protected void UnwireButtonEvents()
Detaches event handlers from the text box and other child elements.
protected virtual void UnwireEvents()
Validates the current value and updates the display if necessary.
Performs core validation logic for the current internal value.
protected virtual void ValidateCore()
Validates the input on key press and handles Enter key for value validation.
protected virtual void ValidateOnKeyPress(KeyPressEventArgs e)
A KeyPressEventArgs that contains the event data.
Attaches event handlers to the increment and decrement buttons.
protected void WireButtonEvents()
Attaches event handlers to the text box and other child elements.
protected virtual void WireEvents()
Events
Occurs when the user presses a key while the spin element has focus.
public event KeyEventHandler KeyDown
Occurs before the value of the spin element has changed.
[Browsable(true)]
public event EventHandler ValueChanged
Occurs when the value is being changed. This is a cancelable event.
public event ValueChangingEventHandler ValueChanging