Category / Section
What is the purpose of ValueChangeMode in SfNumericTextBox?
1 min read
The ValueChangeMode property is used to update the value property when a key is pressed or focus is lost. It contains two options described below:
- OnLostFocus
- OnKeyFocus
OnKeyFocus: When the ValueChangeMode is OnKeyFocus, the value will be changed for each keypress. The following code demonstrates how to set the ValueChangeMode as OnKeyFocus.
Code Snippet
XAML Code
<Grid x:Name="Grid1" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <syncfusion:SfNumericTextBox x:Name="Numeric1" Width="200" Height="23" ValueChangedMode="OnKeyFocus"/> </Grid>
C# Code
public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); SfNumericTextBox NumericTextBox1 = new SfNumericTextBox(); NumericTextBox1.Width = 200; NumericTextBox1.Height = 23; NumericTextBox1.ValueChangedMode = ValueChange.OnKeyFocus; Grid1.Children.Add(NumericTextBox1); } }
OnLostFocus: The value in the SfNumericTextBox change will be updated when the control is no longer focused. The following code demonstrate how to set the ValueChangedMode property as OnLostFocus.
Code Snippet
XAML Code
<Grid x:Name="Grid1" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <syncfusion:SfNumericTextBox x:Name="Numeric1" Width="200" Height="23" Value="123.56" ValueChangedMode="OnLostFocus"/> </Grid>
C# Code
public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); SfNumericTextBox NumericTextBox1 = new SfNumericTextBox(); NumericTextBox1.Width = 200; NumericTextBox1.Height = 23; NumericTextBox1.ValueChangedMode = ValueChange.OnLostFocus; Grid1.Children.Add(NumericTextBox1); } }