//telerik
private void _CheckIFnDataGrid_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement.ColumnInfo.Name == "CheckOpName" && e.CellElement.RowInfo is GridViewDataRowInfo)
{
//把已经报修过的项目禁用掉
if (e.CellElement.Value.ToString().Contains("已报修"))
{
e.CellElement.BackColor = Color.Red;
}
else
{
e.CellElement.BackColor = Color.Orange;
e.CellElement.Enabled = true;
}
e.CellElement.Font = new Font("微软雅黑", 12, FontStyle.Bold);
e.CellElement.DrawFill = true;
e.CellElement.GradientStyle = GradientStyles.Solid;
e.CellElement.ForeColor = Color.Blue;
}
}
//winfrom自带
private void _CheckIFnDataGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.RowIndex != -1 && _CheckIFnDataGrid.Columns[e.ColumnIndex].Name == "Option")
{
e.CellStyle.BackColor = Color.Red;
e.CellStyle.ForeColor = Color.Orange;
e.CellStyle.Font = new Font("微软雅黑", 15, FontStyle.Bold);
e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold);
}
if (e.RowIndex != -1 && _CheckIFnDataGrid.Columns[e.ColumnIndex].Name == "CheckOpName")
{
//把已经报修过的项目禁用掉
if (_CheckIFnDataGrid.Rows[e.RowIndex].Cells["CheckOpName"].Value.ToString().Contains("已报修"))
{
e.CellStyle.BackColor = Color.Red;
}
else
{
e.CellStyle.BackColor = Color.Orange;
//e.CellElement.Enabled = true;
}
e.CellStyle.Font = new Font("微软雅黑", 12, FontStyle.Bold);
e.CellStyle.ForeColor = Color.Blue;
}
}