I want my datacolumns in my Windows.Forms.Datagrid to show like Excel, 开发者_StackOverflowred for negative numbers in brackets, and black for positive numbers.
Also i want to right align the cells, but left align the header. Is this possible?
Something like this should work for alignment:
var cellStyle = new System.Windows.Forms.DataGridViewCellStyle()
cellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight
dataGridColumn.DefaultCellStyle = cellStyle
For coloring you should probably handle some datagrid paint event and select different DataGridViewCellStyle for negative numbers.
精彩评论