Articles in this section

How to Restrict Null Values in the SfNumberBox Control?

This section explains how to restrict null values in the SfNumberBox control using the AllowNull property.

Behavior of Null Value

By default, the SfNumberBox allows an empty or null value when the input is cleared, as the AllowNull property is set to true.

When AllowNull is set to false, clearing the input will reset the value to 0 instead of leaving it empty.

For example, if the Minimum value is set to 15 and AllowNull is true, clearing the input will result in a null value in the SfNumberBox.

XAML

<editors:SfNumberBox HorizontalAlignment="Center"
                    VerticalAlignment="Center" 
                    Value="10" 
                    AllowNull="False" /> 

C#

SfNumberBox sfNumberBox = new SfNumberBox();
sfNumberBox.HorizontalAlignment = HorizontalAlignment.Center;
sfNumberBox.VerticalAlignment = VerticalAlignment.Center;
sfNumberBox.Value = 10;
sfNumberBox.AllowNull = false; 

restrict_nullvalue.gif

Conclusion

I hope you enjoyed learning about how to restrict the change in value of the NumberBox control.

You can refer to our WinUI NumberBox feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the Licence and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forum, Support portal, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied