سؤال

Is there some trick to setting the back color of the row in the Telerik WinForms RadGridView at runtime in the RowFormatting event? I am able to set the RowElement.Font in this event but not the RowElement.BackColor. I have stepped through the code in the debugger and am certain that the line is being executed (the event is properly "wired up").

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;
                }

     }
هل كانت مفيدة؟

المحلول

Your code looks good, you just need to set DrawFill to true Add this:

e.RowElement.DrawFill = true;      

Full example:

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;
                }

     }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top