C# DataGridView设置背景颜色、文字颜色及文字样式

客官°小女子只卖身不卖艺 2022-09-10 10:26 1145阅读 0赞
  1. //行表头和列表头文字颜色
  2. dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.DarkSlateGray;
  3. dataGridView1.RowHeadersDefaultCellStyle.BackColor = Color.DarkSlateGray;
  4. //行表头和列表头文字颜色
  5. dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.Cyan;
  6. dataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font("楷体", 12, FontStyle.Bold);
  7. dataGridView1.RowHeadersDefaultCellStyle.ForeColor = Color.Cyan;
  8. dataGridView1.RowHeadersDefaultCellStyle.Font = new Font("楷体", 12, FontStyle.Bold);
  9. //表格背景色
  10. dataGridView1.DefaultCellStyle.BackColor = Color.DarkSlateGray;
  11. dataGridView1.DefaultCellStyle.SelectionBackColor = Color.Teal;
  12. //表格文字样式
  13. dataGridView1.RowsDefaultCellStyle.Font = new Font("楷体", 12, FontStyle.Bold);
  14. dataGridView1.RowsDefaultCellStyle.ForeColor = Color.Cyan;
  15. dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Yellow;
  16. dataGridView1.EnableHeadersVisualStyles = false;

发表评论

表情:
评论列表 (有 0 条评论,1145人围观)

还没有评论,来说两句吧...

相关阅读