开发者

How do I style Windows.Forms.Datagrid numbers to show like Excel?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜