How to set the decimal formats for a particular column in WinForms GridControl?
Number in decimal format
You can set the number with decimal format programmatically for a particular column in a GridControl, by setting the ColStyles[index].Format property.
C#
// used to display one decimal precision ( e.g ‘#.0’) this.gridControl1.ColStyles[1].Format = "N1"; // used to display two decimal precision ( e.g ‘#.00’) this.gridControl1.ColStyles[2].Format = "N2"; // used to display three decimal precision ( e.g ‘#.000’) this.gridControl1.ColStyles[3].Format = "N3"; // used to display the default currency symbol "$" and two decimal precision ( e.g ‘$#.00’). this.gridControl1.ColStyles[4].Format = "C";
VB
' used to display one decimal precision ( e.g ‘#.0’) Me.gridControl1.ColStyles(1).Format = "N1" ' used to display two decimal precision ( e.g ‘#.00’) Me.gridControl1.ColStyles(2).Format = "N2" ' used to display three decimal precision ( e.g ‘#.000’) Me.gridControl1.ColStyles(3).Format = "N3" ‘used to display the default currency symbol "$" and two decimal precision ( e.g ‘$#.00’). Me.gridControl1.ColStyles(4).Format = "C"
The following screenshot illustrates the output.
Figure 1: Number in decimal format
Conclusion
I hope you enjoyed learning about how to set the decimal formats for a particular column in WinForms GridControl.
You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridControl documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!