实现GridControl行动态改变行字体和背景色

 需求:开发时遇到一个问题, 需要根据GridControl行数据不同,实现不同的效果

  在gridView的RowCellStyle的事件中实现,需要的效果

        private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            string accountQuantity = gridView1.GetRowCellValue(e.RowHandle, "ACCOUNT_QUANTITY").ToString();
            string actualQuantity = gridView1.GetRowCellValue(e.RowHandle, "ACTUAL_QUANTITY").ToString();
            if (accountQuantity != actualQuantity)
            {
                // e.Appearance.BackColor = Color.Red;//改变背景色
                e.Appearance.ForeColor = Color.Red;//改变字体颜色
            }
        }

posted @ 2016-01-26 21:08  高空燕子飞过  阅读(4954)  评论(0编辑  收藏  举报