Articles in this section
Category / Section

How to change the Culture of NumericTextBox

1 min read

The SfNumericTextBox’s value can be localized to any specific culture. It can be specified by setting “Culture” property. Default culture property value is “en-US”.

 

The following steps will helpful to set the culture of your NumericTextBox’s value

 

Step 1: Add the required assemblies for getting NumericTextBox.

 

Step 2: Change the Culture property of NumericTextBox with your culture with format string value of currency (c symbol)

 

Code Example:

 

namespace KBSolution
{
public partial class KBSolutionPage : ContentPage
{
    public KBSolutionPage()
    {
        InitializeComponent();
 
        Grid grid = new Grid() { BackgroundColor = Color.FromHex("E4EAF0") };
        grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
        grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
 
        Label firstNumeric = new Label()
        {
            Text = "NumericTextBox",
            FontSize = 20,
            HorizontalOptions = LayoutOptions.Center,
            FontAttributes = FontAttributes.Bold,
            HorizontalTextAlignment = TextAlignment.Start,
            VerticalTextAlignment = TextAlignment.Start
        };
        SfNumericTextBox sfNumericTextBox = new SfNumericTextBox()
        {
            WidthRequest = 180,
            ParserMode = Parsers.Decimal,
            HorizontalOptions = LayoutOptions.Center,
            MaximumNumberDecimalDigits = 3,
            AllowNull = true,
            BorderColor = Color.Blue,
            TextColor = Color.Maroon,
            Value = 1000,
// culture property to change the culture of numericTextBox
            Culture = new System.Globalization.CultureInfo("ja-JP"),
            FormatString = "c",
            ValueChangeMode = ValueChangeMode.OnKeyFocus,
            PercentDisplayMode = PercentDisplayMode.Value,
            FontSize = 20
 
        };
 
        grid.Children.Add(firstNumeric, 0, 0);
        grid.Children.Add(sfNumericTextBox, 0, 1);
 
        this.Content = grid;
    }
}
}

 

 

 

SfNumericTextBox Currency Format

 

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