实现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;//改变字体颜色
            }
        }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM