This is a migrated thread and some comments may be shown as answers.

Allow comma and dot as decimal separator in GridViewDataColumn

1 Answer 178 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bernard
Top achievements
Rank 1
Bernard asked on 20 Jan 2012, 03:54 PM
Hi,

I would like to allow either comma and dot as decimal separator in GridViewDataColumn.

<telerik:GridViewDataColumn Header="Qté" DataMemberBinding="{Binding Quantity, Mode=TwoWay}"/>

Where Quantity is :

private double _quantity;
        public double Quantity
        {
            get { return OrderUnit == PackagingUnit.Kilogram ? Math.Round(_quantity, 3) : Math.Round(_quantity, 0); }
            set
            {
                if (_quantity == value) return;
                _quantity = value;
                RaisePropertyChanged(ReflectionUtility.GetPropertyName(() => Quantity));
 
                Refresh();
            }
        }

The ViewModel set those parameters in constructor :

var culture = new CultureInfo("fr-FR", false);
 
            culture.NumberFormat.CurrencyDecimalSeparator = ".";
            culture.NumberFormat.NumberDecimalSeparator = ".";
            culture.NumberFormat.PercentDecimalSeparator = ".";
 
            culture.Parent.NumberFormat.CurrencyDecimalSeparator = ".";
            culture.Parent.NumberFormat.NumberDecimalSeparator = ".";
            culture.Parent.NumberFormat.PercentDecimalSeparator = ".";
 
            LocalizationManager.DefaultCulture = culture;
 
            Dispatcher.CurrentDispatcher.Thread.CurrentCulture = culture;
            Dispatcher.CurrentDispatcher.Thread.CurrentUICulture = culture;
 
            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;

Result :

When the cell isn't in EditMode, if quantity is 4,268, the cell displays 4.27 : it's why I want.

But when the cell is in EditMode: if user write 4.58 for example, the value isn't recognize as a valid double and is converted back. When writting 4,58, the value is successfully recognized.

Thanks

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 20 Jan 2012, 05:41 PM
Hi,

Indeed, the French culture requires a comma "," decimal separator. Please take a look at this forum post where you could find a discussion about the decimal separators.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Bernard
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or