110,538
社区成员
发帖
与我相关
我的任务
分享
for(int i=0;i<dataGridView2.Rows.Count;i++)
{
if (dataGridView2.Rows[i].Cells[1].Value.ToString() == "加急")
{
e.CellStyle.BackColor = Color.Red;
e.FormattingApplied = true;
}
}
private void makerowpink(DataGridView dgv)
{
for (int i = 0; i < dgv.Rows.Count; i++)
{
if (dgv.Rows[i].Cells["fanlulevel"].Value.ToString().Trim() == "加急")
{
dgv.Rows[i].DefaultCellStyle.BackColor = Color.Pink;
}
}
}
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
DataGridView dgv = (DataGridView)sender;
if (dgv.Columns[e.ColumnIndex].Name == "fanlulevel" && e.Value is string)
{
string str = e.Value.ToString();
if (str == "加急")
{
dgv.DefaultCellStyle.BackColor = Color.Pink;
}
// 应用该Format,Format完毕。
e.FormattingApplied = true;
}
}
for(int i=0;i<dataGridView2.Rows.Count;i++)
{
if (dataGridView2.Rows[i].Cells[1].Value.ToString() == "加急")
{
//e.CellStyle.BackColor = Color.Red;
//e.FormattingApplied = true;
//这段代码要放在什么事件里才能实现类似上面两句注释掉的语句的效果呢?
}
}