How can i implement an Excel accounting format in the Syncfusion WinForms GridControl

9 Dec 2019 / 1 minute to read

We can achieve this behavior by setting the cell type to Currency. The currency symbol is removed from the cell data with the following code:

this.gridControl1[i, j].CurrencyEdit.CurrencySymbol = "";
Me.gridControl1[i, j].CurrencyEdit.CurrencySymbol = "";

The CurrencyDecimalDigits property is used and the digits after the decimal point are set using the code below:

this.gridControl1[i, j].CurrencyEdit.CurrencyDecimalDigits = 2;
Me.gridControl1[i, j].CurrencyEdit.CurrencyDecimalDigits = 2;

By default the contents are left-aligned, so the horizontal alignment is set to Right.

this.gridControl1.ColStyles[j].HorizontalAlignment = Syncfusion.Windows.Forms.Grid.GridHorizontalAlignment.Right;
Me.gridControl1.ColStyles[j].HorizontalAlignment = Syncfusion.Windows.Forms.Grid.GridHorizontalAlignment.Right;