如何DevExpress,GridControl,FocusedRow只改變背景色、不改變ForeColor前景色(change the background not fore colors)

困擾我好幾天的一個問題、今天終於解決了.....................奮鬥

GridControl的可以設置FocusedRow的前景色和背景色、但是由於前景色已經動態生成、所以不想被覆蓋,英文大致爲這樣描述

by default the grid changes the cell's ForeColor when the row is focused and painted with a different background (AllowCellFocus turned off). How can I have the focused row still show the original ForeColors of all the cells in the row and not overpaint it with a specific ForeColor for focused rows?

 

 If I do that I can't highlight a focused row with a background color anymore. I want to still be able to change the background on row

focus but I want the fore colors to remain the same as in the unfocused cells.

 

大致就是:改變FocusedRow的背景色,但是不改變前景色

兩步即可:

1、EnableAppearanceFocusedCell = False, EnableAppearanceFocusedRow = False

2、在代碼裏面給FocusedRow你想要的背景色、

 private void gdvMarket_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
            if (e.RowHandle == gdvMarket.FocusedRowHandle)
            {
               
               e.Appearance.BackColor=Color.CadetBlue;
              ;
            }
        }

發佈了112 篇原創文章 · 獲贊 19 · 訪問量 29萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章