2012-12-10 60 views
0

在RowFormatting事件中,在運行時在Telerik WinForms RadGridView中設置行的背色是否有一些技巧?我可以在此事件中設置RowElement.Font,但不能在RowElement.BackColor中設置。我已經在調試器中加入了代碼,並確定該行正在執行(事件已正確「連線」)。在RowFormatting事件中設置Telerik RadGridView(WinForms)中的RowElement.BackColor

void grid_RowFormatting(object sender, Telerik.WinControls.UI.RowFormattingEventArgs e) 
    { 
     if (e.RowElement.RowInfo.Cells["CODE"].Value.ToString() == "X")) 
       { 
        // the following line is executed but has no apparent effect 
        e.RowElement.BackColor = System.Drawing.Color.Aqua; 
       } 

    } 

回答

2

你的代碼看起來不錯,你只需要設置DrawFilltrue 補充一點:

e.RowElement.DrawFill = true;  

完整的示例:

void grid_RowFormatting(object sender, Telerik.WinControls.UI.RowFormattingEventArgs e) 
    { 
     if (e.RowElement.RowInfo.Cells["CODE"].Value.ToString() == "X")) 
       { 
        e.RowElement.DrawFill = true; 
        e.RowElement.BackColor = System.Drawing.Color.Aqua; 
       } 

    } 
+0

:感謝您的信息! – Tim

相關問題