Hi,
I need to put commas in my decimal type column which actually has currency data in it. I understand that I cannot append dollar sign without changing it to string datatype but is there any way I can format it with commas and It would still sort as decimal type column.
Thanks,
Kavita
Forgive me if I am oversimplifying this but if you want to show commas for currency value s, just assing the value "c" to the UltraGridColumn's Format property. This will not affect sorting because the decimal data type implements IComparable, and UltraGrid's default sorting logic will use the IComparable implementation when it finds one.
Brian,
I tried setting the Column's format property to "c". It working fine for positive values but for negative values it shows -19876 = ($19,876). Removes the negative sign and appends opening and closing round brackets.
Please suggest something!
From what I recall accountants use paretheses to denote negative values, and apparently whatever culture you are running under uses that representation by default. Try setting the System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyNegativePattern to change it.
I set the Column's format property equal to "$#,##0.00" and this formats the positive as well as the negative values correctly.
Using Format="###,###,##0.00" for my decimal column works perfectly now but it took me forever to figure out why it wasn't working initially. The issue was that I had the DataType as "Decimal" - it should be "System.Decimal" instead. Before I change the dataType to "System.Decimal" it was assuming string data type and was neither formatting nor sorting correctly.