给DatagridView 设置 列和行 的标题背景色 怎么没有效果?????
给DatagridView 设置 列和行 的标题背景色 怎么没有效果?????
foreach (DataGridViewRow row in dataGridView1.Rows )
{
if (Convert.ToInt32(row.Cells["Emp_Age"].Value) < 18 && Convert.ToInt32(row.Cells["Emp_Age"].Value)>=1)
{
row.HeaderCell.Style.BackColor = Color.Red;
row.Cells["Emp_Age"].Style.BackColor = Color.Red;
dataGridView1.Columns[row.Cells["Emp_Age"].ColumnIndex].HeaderCell.Style.BackColor = Color.Red;
row.Cells["Emp_Age"].Style.Font = new Font(dataGridView1.Font, FontStyle.Bold);
row.Cells["Emp_Age"].Style.Alignment = DataGridViewContentAlignment.MiddleRight;
}
}
高手指点!!!!