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

problem with negative sign in right-to-left grid

3 Answers 177 Views
GridView
This is a migrated thread and some comments may be shown as answers.
moj
Top achievements
Rank 1
moj asked on 14 Jun 2019, 12:34 PM

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

3 Answers, 1 is accepted

Sort by
0
Nadya
Telerik team
answered on 18 Jun 2019, 02:04 PM
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.
0
moj
Top achievements
Rank 1
answered on 22 Jun 2019, 04:47 PM

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 ?

 


0
Nadya
Telerik team
answered on 25 Jun 2019, 04:56 AM
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.
Tags
GridView
Asked by
moj
Top achievements
Rank 1
Answers by
Nadya
Telerik team
moj
Top achievements
Rank 1
Share this question
or