Events and Interactivity

17 Jan 20251 minute to read

Events

ValueChanged

You can perform any operation when changing the value of SfNumericTextBox using the ValueChanged event. The ValueChanged event returns the changed value in SfNumericTextBox.

For example you can restrict the SfNumericTextBox value if it exceed’s greater than 3 digits using following code.

  • C#
  • [C#]
    
    SfNumericTextBox numericTextBox = new SfNumericTextBox()
    {
        Value = 123,
    	ValueChangeMode = SFNumericUpDownValueChangeMode.OnKeyFocus,
    };
    
    
    numericTextBox.ValueChanged += (object sender, Syncfusion.SfNumericTextBox.iOS.ValueEventArgs e) =>
    {
        //Do the action when changed the value property.
    };
    
    this.Add(numericTextBox);

    Interactivity : ValueChangeMode

    The ValueChangeMode property is used to mention when value needs to update, either in key pressed or focus lost state. When ValueChangeMode is set to OnKeyFocus, the value will be updated on each key press. When ValueChangeMode is set to OnLostFocus, the value is updated when the control lose the focus or the focus is moved to the next control. ValueChangeMode includes the following options:

    1. OnKeyFocus
    2. OnLostFocus

    OnKeyFocus

  • C#
  • [C#]
    
    SfNumericTextBox numericTextBox = new SfNumericTextBox()
    {
        Value = 123,
    	ValueChangeMode = SFNumericTextBoxValueChangeMode.OnKeyFocus,
    };

    OnLostFocus

  • C#
  • [C#]
    
    SfNumericTextBox numericTextBox = new SfNumericTextBox()
    {
    	
        Value = 123,
    	ValueChangeMode = SFNumericTextBoxValueChangeMode.OnLostFocus,
    };

    Selection Support in SfNumericTextBox

    The SelectAllOnFocus property is used to specify whether the text should be selected when the control gets focus.

  • C#
  • [C#]
    
    numericTextBox.SelectAllOnFocus = true;