實現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