We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Format a column with negative currency value

Hi Team,

Just wonder if we can format the column with negative currency value, such that the cell will display -$12.00 instead of ($12.00)

My understand is that the parenthesis is set up by the default CurrencyNegativePattern prop,  how can we override it and setting it to 1? Or we can only use Formatter to manually put a string "-" before the formatted data ?

1 Reply

VN Vignesh Natarajan Syncfusion Team January 14, 2020 04:51 AM UTC

Hi Feifan, 
 
Greetings from Syncfusion support.  
 
Query: “ how can we override it and setting it to 1? Or we can only use Formatter to manually put a string "-" before the formatted data ? 
 
We suggest you to achieve your requirement (to display negative sign with currency symbol) using Column Template feature of Grid. Inside the template you can change the Current CultureInfo like below.  
 
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"> 
            <Template> 
                @{ 
                    var ord = (context as Order).Freight; 
                    CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; 
                    CultureInfo newCulture = new CultureInfo("en-US"); 
                    newCulture.NumberFormat.CurrencyNegativePattern = 1; 
                    Thread.CurrentThread.CurrentCulture = newCulture; 
                    <span>@ord.ToString("C2")</span> 
                } 
            </Template> 
        </GridColumn> 
 
Refer our UG documentation for your reference 
 

Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan. 


Loader.
Live Chat Icon For mobile
Up arrow icon