C# WinForm 查询时设置DataGridView 的颜色

 用:CellPainting 事件去修改颜色不会那么卡

private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {

            if (e.ColumnIndex >= 0 && rcomdgv1.Columns[e.ColumnIndex].Name == "字段名称")
            {
                if (Collections.Entity.to_double(e.Value) > 0)
                {
                    e.CellStyle.BackColor = Color.Red;
                }
                else
                { }
            }
          
         
        }

posted @ 2022-01-13 14:16  LuoCore  阅读(91)  评论(0编辑  收藏  举报