C#:DataGridView边框线、标题、单元格的各种颜色

  1. //包含Header所有的单元格的背景色
  2.  
    DataGridView1.DefaultCellStyle.BackColor
  3.  
     
  4.  
    //包含Header所有的单元格的前景色
  5.  
    DataGridView1.DefaultCellStyle.ForeColor
  6.  
     
  7.  
    //包含Header所有的单元格的背景色
  8.  
    DataGridView1.DefaultCellStyle.BackColor
  9.  
     
  10.  
    // Header以外所有的单元格的背景色
  11.  
    DataGridView1.RowsDefaultCellStyle.BackColor
  12.  
     
  13.  
    //奇数行的单元格的背景色
  14.  
    DataGridView1.AlternatingRowsDefaultCellStyle.BackColor
  15.  
     
  16.  
    //列Header的背景色
  17.  
    DataGridView1.ColumnHeadersDefaultCellStyle.BackColor
  18.  
     
  19.  
    //行Header的背景色
  20.  
    DataGridView1.RowHeadersDefaultCellStyle.BackColor
  21.  
     
  22.  
    //边框线的颜色
  23.  
    DataGridView1.GridColor
  24.  
     
  25.  
    //如果想让标题的边框线和颜色生效还需要如下设置
  26.  
    DataGridView1.EnableHeadersVisualStyles=false;
原文地址:https://www.cnblogs.com/skyay/p/13737252.html