【问题标题】:set RowElement.BackColor in Telerik RadGridView (WinForms) in RowFormatting event在 RowFormatting 事件中设置 Telerik RadGridView (WinForms) 中的 RowElement.BackColor
【发布时间】:2012-12-10 20:09:54
【问题描述】:

在运行时在 RowFormatting 事件中设置 Telerik WinForms RadGridView 中行的背景颜色是否有一些技巧?我可以在此事件中设置 RowElement.Font,但不能设置 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;
                }

     }

【问题讨论】:

    标签: telerik radgridview backcolor


    【解决方案1】:

    您的代码看起来不错,您只需将DrawFill 设置为true 添加这个:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-28
      • 2021-04-29
      • 1970-01-01
      • 2021-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多