Back to Devexpress

DxSpinEdit<T>.ValueChanging Event

blazor-devexpress-dot-blazor-dot-dxspinedit-1-c3855415.md

latest2.2 KB
Original Source

DxSpinEdit<T>.ValueChanging Event

Fires when a user is changing the Spin Edit’s value. Use this event to validate/cancel user input.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public Action<ParameterValueChangingEventArgs<T>> ValueChanging { get; set; }

Event Data

The ValueChanging event's data class is ParameterValueChangingEventArgs<T>. The following properties provide information specific to this event:

PropertyDescription
NewValueGets or sets the new value being assigned to the parameter.
OldValueGets the current parameter value.

Remarks

The ValueChanging event fires before a new value is applied to the editor (before the ValueChanged event). You can use this event to validate/cancel user input.

The following code snippet automatically formats numbers and handles the ValueChanging event to limit the value range (1 - 100). The current value is updated via two-way binding (@bind-Value).

razor
<DxSpinEdit @bind-Value="@Amount"
            ValueChanging="@OnValueChanging"
            DisplayFormat="N0">
</DxSpinEdit>

<div class="mt-2">
    <span>Current amount: @Amount</span>
</div>

@code {
    int Amount { get; set; } = 50;

    private void OnValueChanging(ParameterValueChangingEventArgs<int> e) {
        if (e.NewValue < 1 || e.NewValue > 100) {
            e.NewValue = e.OldValue;
        }
    }
}

Note

The Spin Edit also supports numeric masks that allow you to define the input format.

See Also

DxSpinEdit<T> Class

DxSpinEdit<T> Members

DevExpress.Blazor Namespace