简体   繁体   中英

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

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 entire 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;

或者列[1],如果这就是你的意思。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM