c# - RadGridView 改变文字颜色

标签 c# wpf telerik telerik-grid radgridview

我有一个简单的 RadGridView,我想在其中更改特定行(= 3 个单元格)的文本颜色。不幸的是,这段代码不起作用:

//add new row to the grid
EventLogGrid.Items.Add(new EventLogRow(eventType, occured, msg));

//change the color of the text of all cells if it's an exception
if (eventType == EventLogger.EventType.Exception)
{
  var rows = this.EventLogGrid.ChildrenOfType<GridViewRow>();
  rows.Last().Foreground = new SolidColorBrush(Colors.Yellow);
}

如有任何意见,我们将不胜感激。

最佳答案

实际上有一个非常简单的解决方案:

  1. 附加一个事件处理器:

    EventLogGrid.RowLoaded += EventLogGrid_RowLoaded;
    
  2. 改变行的颜色:

    if (((EventLogRow)e.DataElement).MsgType == EventLogger.EventType.Exception)
    {
       e.Row.Foreground = new SolidColorBrush(Colors.Red);
    }
    

关于c# - RadGridView 改变文字颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14103539/

相关文章:

c# - Linq 延迟操作

c# - 如何加密msmq消息?

telerik - Sitefinity 多语言网站图片(未翻译)问题

javascript - Mobiscroll Datepicker Kendo UI 移动版

c# - 如何根据 ASP.NET//C# 中的内容更改 ListView 中图像的 CSS 类

C# - 如何获取当前光标状态(如果当前是箭头、手、等待等)

wpf - 有没有办法改变WPF中的绘制顺序

c# - 移植WinForms拖拽到WPF拖拽

c# - 如何卡住无法卡住的可卡住对象

javascript - 网格初始化后的 Kendo 网格事件处理