problem with negative sign in right-to-left grid

4 posts, 0 answers
  1. moj
    moj avatar
    11 posts
    Member since:
    Jun 2019

    Posted 14 Jun Link to this post

    Hello
    Have problem with negative sign in grid with right-to-left =true

    the negative numeric values are displayed like:
    10-
    20-
    300-
    instead of:
    -10
    -20
    -300

    I use decimal Column

  2. Nadya
    Admin
    Nadya avatar
    41 posts

    Posted 18 Jun Link to this post

    Hello, Moj, 

    Right-to-left mode is used for certain languages such as Arabic, where people read and write starting from the right side of the page. So having the minus sign appear to the right in the RadGridView is natural. 

    However, you want to set the alignment of the text from left to right in GridViewDecimalColumn with negative numbers. In this case, you can subscribe to the CellFormatting event and set RightToLeft property to false. Please refer to the following code snippet which demonstrates how to achieve the illustrated result:

    private void RadGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
    {
        if (e.Column.Name == "NumberColumn")
        {
            e.CellElement.RightToLeft = false;
        }
        else
        {
            e.CellElement.ResetValue(RadElement.RightToLeftProperty);
        }
    }



    I hope this information helps. If you need any further assistance please don't hesitate to contact us.

    Regards,
    Nadya
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. moj
    moj avatar
    11 posts
    Member since:
    Jun 2019

    Posted 22 Jun in reply to Nadya Link to this post

    Hello
    Very thanks for reply

    This way is correct.
    In Right-to-left  languages such as Arabic position  minus in left of number

    Can solved problem without change RightToLeft column property ?

     


  4. Nadya
    Admin
    Nadya avatar
    41 posts

    Posted 24 Jun Link to this post

    Hello Moj,

    You can also use a custom numeric format string which allows to format numeric data in a custom way:
    decimalColumn.FormatString = "{0:#,0;#,0-}";

    Additional information about custom numeric format strings is available in the following article: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings

    Let me know how this works for you.

    Regards,
    Nadya
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top