GridView控件绑定事件:

            gridView_SampleData.CustomDrawCell += gridView_SampleData_CustomDrawCell;

根据自定义逻辑来改变行属性,例子是判断某个单元格的Is duplicated列是否为yes,若是,则将行标记为黄色。

        //自定义画某行
private void gridView_SampleData_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (gridView_SampleData.GetRow(e.RowHandle) == null)
return;
else
{
//隐藏标记行
if (gridView_SampleData.Columns["Is duplicated"] != null)
{
gridView_SampleData.Columns["Is duplicated"].VisibleIndex = -;
//获取所在行指定列的值
string duplicated = gridView_SampleData.GetRowCellValue(e.RowHandle, "Is duplicated").ToString();
//设置此行的背景颜色
if (duplicated == "yes")
e.Appearance.BackColor = Color.Yellow;
}
}
}
04-14 08:07