DevExpress.XtraGrid.Views 设置指定行的背景颜色 .

如需要将指定行的背景设置颜色,可参考以下示例

1.事件:CustomDrawCell

2.示例:

 private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (gridView1.GetRow(e.RowHandle) == null)
            {
                return;
            }
            else
            {

                //获取所在行指定列的值
                double state = ylbasicpub.YLCover.StrToDouble(gridView1.GetRowCellValue(e.RowHandle,
                    "用地总面积").ToString());

                //比较指定列的状态
                if (state > 0)
                {
                    e.Appearance.BackColor = Color.NavajoWhite;//设置此行的背景颜色
                }
            }

        }

原文地址:https://www.cnblogs.com/gisoracle/p/5671583.html