DEV GridControl ID相同的行显示相同的颜色(当ID的值不确定时)

基于DEV1.1.2 CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)存在BUG,经过测试研究,使用以下方法

private void gridViewCarList_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
{
DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
if (e.RowHandle >= 0)
{
string id = view.GetRowCellDisplayText(e.RowHandle, this.colRowCountID);

if (Convert.ToInt32(id) % 3 == 1)
{
e.CellStyle.BackColor = Color.Bisque;
}

if (Convert.ToInt32(id) % 3 == 2)
{
e.CellStyle.BackColor = Color.CornflowerBlue;
}

if (Convert.ToInt32(id) % 3 == 0)
{
e.CellStyle.BackColor = Color.White;
}
}
}

posted @ 2012-07-26 10:52  沙耶  阅读(1373)  评论(0编辑  收藏  举报