0

I have a radgridview (is from telerik, but it's like a DataGrid) with multiple decimal columns. They should be shown like this: 10'000.00

That's working correctly with this:

<telerik:GridViewDataColumn Header="Total" DataMemberBinding="{Binding Total, StringFormat=N2}">

But if I edit the cell it is show in a wrong format: enter image description here

So I tried to create a CellEditTemplate:

<telerik:GridViewDataColumn Header="Betrag Holzbau" DataMemberBinding="{Binding Total, StringFormat=N2}">
     <telerik:GridViewDataColumn.CellEditTemplate>
         <DataTemplate>
             <telerik:RadWatermarkTextBox Text="{Binding Total, StringFormat=N2}"/>
         </DataTemplate>
     </telerik:GridViewDataColumn.CellEditTemplate>
 </telerik:GridViewDataColumn>

But this shows a wrong thounsand separator (’ instead of '): enter image description here

How can I set the format always to this 10'000.00

Presi
  • 806
  • 10
  • 26
  • What culture are you using? Try to set the `Language` property of the `RadWatermarkTextBox` or use a `TextBox`. – mm8 Sep 11 '20 at 12:49
  • I'm using swiss culture (de-ch). I already tried a textbox but it won't work with it. – Presi Sep 11 '20 at 14:35
  • Did you try to set the `Language` property to "de-ch"? Did you try to set the `DataStringFormat` property of the column? – mm8 Sep 11 '20 at 14:42
  • I set `DataFormatString="{}{0:N2}"` on the column. But it didn't work. Should I set Language only on the Textbox or on the RadGridView – Presi Sep 11 '20 at 15:04
  • On the `TextBox`. – mm8 Sep 11 '20 at 15:04
  • I found out that the Textbox has the correct culture. But the `CurrencyGroupSeparator` is wrong. That's very curios. Can I change this only for my textboxes? – Presi Sep 14 '20 at 07:44
  • The culture of the textbox and the Thread is de-CH. The `CurrencyGroupSeperator` is showing ’ instead of ' . But as I know the swiss german useses ' as seperator. This is also set in my Setting of my Windows. So it's wrong in my opinion. Could the culture use the wrong seperator? – Presi Sep 15 '20 at 05:16
  • Wrong or not, it is what it is. Maybe you want to create your own custom culture or convert the value yourself. – mm8 Sep 15 '20 at 13:02
  • Yes, you're right. Thanks for your help. With the CellEditTemplate I could change it and it seems to work now. – Presi Sep 17 '20 at 05:07

1 Answers1

1

You should be able to set the Language property of the TextBox to a culture in the CellEditTemplate to format the number according to that culture.

Then you "only" need to find a culture that uses ' or create your own custom culture.

Another option may to format the value yourself, for example using a value converter.

mm8
  • 163,881
  • 10
  • 57
  • 88