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

Decimal problem!

1 Answer 70 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jose Oliveira
Top achievements
Rank 1
Jose Oliveira asked on 15 Apr 2010, 11:08 AM
Hi there,

when I insert decimal values in datagrid I get diferent results if pressed ',' or '.'

Eg. value 7,25

When I insert 7,25 with ',' the final result is 725

but

When I insert 7,25 with '.' the final result is 7,25

I want that was indiferent press ',' or '.' the final result was always the same!

I check every char insert on the grid but  I CanĀ“t assign olther value to a routed event that is already in use !

 void RadGridView1_KeyDown(object sender, KeyEventArgs e) 
        { 
            if (e.Key == Key.Decimal) 
            { 
                e.Handled = true
                e.Source = "2"; // ==> error 
            } 
            if (e.Key == Key.OemComma) 
            { 
                e.Handled = true
            } 
            if (e.Key == Key.OemPeriod) 
            { 
                e.Handled = true
            } 
        } 




it's possible when the user press ',' change the value to '.' ?

Any ideias?

Thanks,
Jose Oliveira



1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 19 Apr 2010, 10:04 AM
Hello Jose Oliveira,

Instead of listening to every KeyStroke , you might try the following approach :
For your column  DataMemberBinding Binding you may set a custom IValueConverter to take care of parsing the string to the correct decimal.

In the ConvertBack method of the IValueConverter you may write your own logic to correctly parse the input string to a decimal.

Let me know in case you need  assistance with implementing this approach .

All the best,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Jose Oliveira
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or