Stop Automatic Round Up - Round Down

8 posts, 0 answers
  1. SweNz
    SweNz avatar
    18 posts
    Member since:
    Jan 2011

    Posted 19 Aug 2011 Link to this post

    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
  2. SweNz
    SweNz avatar
    18 posts
    Member since:
    Jan 2011

    Posted 21 Aug 2011 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 24 Aug 2011 Link to this post

    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 >>

  5. SweNz
    SweNz avatar
    18 posts
    Member since:
    Jan 2011

    Posted 26 Aug 2011 Link to this post

    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
  6. Sébastien
    Sébastien avatar
    16 posts
    Member since:
    Aug 2012

    Posted 12 Sep 2011 Link to this post

    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
  7. Pana
    Admin
    Pana avatar
    748 posts

    Posted 16 Sep 2011 Link to this post

    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 >>
  8. Sébastien
    Sébastien avatar
    16 posts
    Member since:
    Aug 2012

    Posted 16 Sep 2011 Link to this post

    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
  9. Pana
    Admin
    Pana avatar
    748 posts

    Posted 19 Sep 2011 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready