C# DataGridView 列自动排序时单元格背景色丢失
遇到的问题如题.
一开始我将绘制背景色的话写在 查询按钮下,然后逐行设置背景色.
if (DV.Rows[i].Cells["拣货状态"].EditedFormattedValue.ToString() == "正在拣货")
{
DV.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
}
private void DV_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
if (DV.Rows[e.rowindex].Cells["拣货状态"].EditedFormattedValue.ToString() == "正在拣货")
{
DV.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
}
}