2012-12-17 54 views

回答

3

嘗試

private void dataGridView2_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) 
{ 
    if (e.ColumnIndex == 0) 
     if (dataGridView2[e.ColumnIndex, e.RowIndex].ReadOnly) 
      e.CellStyle.BackColor = Color.Red; 

    if (e.ColumnIndex == 1) 
     if (dataGridView2[e.ColumnIndex, e.RowIndex].ReadOnly) 
      e.CellStyle.BackColor = Color.Black; 
} 
+0

謝謝spajce,它的工作......謝謝alote ... – user1858718

+0

歡迎!.... :) – spajce

2
DataGridViewColumn dgv7col = dgv7.Columns[i]; 
    DataGridViewCell cell = new DataGridViewTextBoxCell(); 
    cell.Style.BackColor = Color.Wheat; 
    dgv7col.CellTemplate = cell; 

你必須定義列不是細胞羅尼

0

簡單:

如果(grdView.Columns [ 「列名」]只讀。) grdView .Columns [「Columnname」]。DefaultCellStyle.BackColor = Color.Lavender;

相關問題