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

Stop Automatic Round Up - Round Down

7 Answers 320 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
SweNz
Top achievements
Rank 1
SweNz asked on 19 Aug 2011, 10:47 AM
Hi Telerik,

I've a trouble..

I set Maximum to 999999 and IsInteger = true which means value can't be more than 999,999 or 6 digits. But when I key in 999999 in my control it round-up and show 1,000,000 ( another i.e. key in 999994 , it round down to 999990 )
How to turn off automatic round function ?

this is my XAML
<telerik:GridViewDataColumn ValidatesOnDataErrors="None" Width="250" DataMemberBinding="{Binding MinAmt}" Header="Minimum Amount" 
                        HeaderTextAlignment="Center" TextAlignment="Right">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding MinAmt, StringFormat='0,0'}" TextAlignment="Right" 
                    x:Name
="MinAmtTextBlock" Loaded="MinAmtTextBlock_Loaded" />
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
<telerik:GridViewDataColumn.CellEditTemplate>
<DataTemplate>
                  <telerik:RadNumericUpDown  Maximum="999999" UpdateValueEvent="PropertyChanged" 
                                            ShowButtons="False" PreviewKeyDown="MinAmt_PreviewKeyDown"
        Value="{Binding Amount, Mode=TwoWay, UpdateSourceTrigger=Explicit}" 
                                            x:Name="MinAmt" Loaded="MinAmt_Loaded" />
</DataTemplate>
</telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>

please give me some advice
Regard,
SweNz

7 Answers, 1 is accepted

Sort by
0
SweNz
Top achievements
Rank 1
answered on 22 Aug 2011, 03:42 AM
Hi there ,

Still need help ..

My business logic is need to set MaxLength or Maximum Value of inputting value (or editing) in a gridview cell.

Thanks a lot,
SweNz
0
Konstantina
Telerik team
answered on 24 Aug 2011, 08:38 AM
Hello Swenz,

Sorry, but I was unable to reproduce the described behavior. Would it be possible to send us your project, so that we can run it here locally and track down the source of the problem. In that way we will be able to provide you with solution in a timely manner.

Looking forward to your reply.

Regards,
Konstantina
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
SweNz
Top achievements
Rank 1
answered on 26 Aug 2011, 10:39 AM
Hi Konstantina,

I can't send you a project because it's a company asset. Btw, Can you suggest me how to deal with following business logic in simplest way

- input field is always in RadGridView
- can set control maximum input length (like TextBox:MaxLength) from code behind.
- input data accepts only Numeric (digit)
- can validate input value after user fill in that control
- can use String Format for add comma ig. if user fill 87654321 after RowEditEnded in ViewMode must shows 87,654,321

looking for your response
Thank you,
SweNz
0
Sébastien
Top achievements
Rank 1
answered on 12 Sep 2011, 07:04 PM
I have a similar problem, and you can reproduce it with your own Q2 2011 samples.
In the NumericUpDown examples, go to the Theming demo, then use the top numeric control, with label NUMERIC FORMAT.
We're trying to use the control to enter credit card numbers. If you try something like 6666666666666012, the control will display
6,666,666,666,666,010, where the last digit is always rounded. If I had entered .....6015, I would have ended up with ......6020.
What's happening here ? The control is bound to a UInt64. Does the control badly support 64-bit numerals ?

Thanks,
Sebastien
0
Pana
Telerik team
answered on 16 Sep 2011, 07:01 AM
Hello Sébastien,

If you are about to enter creadit card numbers I would ask you to consider using RadMaskedInput.

Regards,
Pana
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Sébastien
Top achievements
Rank 1
answered on 16 Sep 2011, 01:13 PM
It's not ALWAYS a credit card. We have to support multiple card formats, but it has to be a Numeric control.
Please tell me how to disable the rounding on the Numeric control.

Sébastien
0
Pana
Telerik team
answered on 19 Sep 2011, 12:08 PM
Hi,

The

Debug

 

 

.WriteLine(((double)(6666666666666012)).ToString("F"));

 

Outputs a 66666666666666010 and the RadNumericUpDown uses a double inside. I believe we are not going to change that.
 
I would suggest you if you are using the field for different cards to use a different approach. For example the user may chose the card type and a different input control would appear for the different types making it using a MaskedInput with different masks for different card types and if a shorter double or int value is required - use numeric.

I am sorry for the inconvenience.

Kind regards,
Pana
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
NumericUpDown
Asked by
SweNz
Top achievements
Rank 1
Answers by
SweNz
Top achievements
Rank 1
Konstantina
Telerik team
Sébastien
Top achievements
Rank 1
Pana
Telerik team
Share this question
or