开发者

Change Font Color of a Column in a DataGridView Control (C# winforms)

开发者 https://www.devze.com 2023-01-11 16:28 出处:网络
I have a DataGridView control with two columns. The default color of the text is black. Is it possible to set the fore color of the entir开发者_如何学运维e second row to gray?(or any other color)..

I have a DataGridView control with two columns. The default color of the text is black. Is it possible to set the fore color of the entir开发者_如何学运维e second row to gray?(or any other color)..

    COLUMN1 | COLUMN2
    -----------------
     black  | gray
     black  | gray
     black  | gray

Please help.. thanks.


Your subject and question are confusing, one refers to the column and one to the rows but anyway.

grid.Columns[1].DefaultCellStyle.ForeColor = Color.Gray;

should handle the column color.

grid.Rows[1].DefaultCellStyle.ForeColor = Color.Gray;

should handle the row color.


dgv.Rows[1].DefaultCellStyle.ForeColor = Color.Gray;

or Columns[1], if that's what you meant.

0

精彩评论

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