【问题标题】:change column value and textcolor while loading silverlight telerik radgrid在加载 silverlight telerik radgrid 时更改列值和文本颜色
【发布时间】:2014-12-17 13:40:44
【问题描述】:

谁能帮我从代码隐藏中更改 silverlight telerik gridview 单元格的前景色和文本。

我的实际要求是,

我有一个包含数据的数据集。很少有列包含前缀为“r_”的数据。现在我需要在网格中显示这些数据。前缀为“r_”的列应显示为红色。我还应该在网格中显示它之前删除该前缀。

例如:我的数据集

Column1          Column2         Column3
Test1            Test2           Test3
Test4            r_Test5         Test6
r_Test7          Test8           r_Test9

在上述示例中,r_Test5、r_Test7 和 r_Test9 应分别显示为 Test5、Test7 和 Test9,但显示为红色。

【问题讨论】:

    标签: silverlight telerik-grid


    【解决方案1】:

    没关系。找到了解决方案。

    private void dgBank_CellLoaded(object sender, Telerik.Windows.Controls.GridView.CellEventArgs e)
        {
            if (e.Cell is GridViewCell && ((e.Cell.Column).Header== "Column_1") || ((e.Cell.Column).Header== "Column_2") || ((e.Cell.Column).Header== "Column_3"))
            {
                TextBlock txt = e.Cell.Content as TextBlock;
                txt.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
    
                if (txt.Text.StartsWith("r_"))
                {
                    var cell = e.Cell;
                    txt.Foreground = new SolidColorBrush(Color.FromArgb(120, 255, 0, 0));
                    txt.Text = txt.Text.Replace("r_", string.Empty);
                }
            }
        }
    

    谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-29
      • 1970-01-01
      • 1970-01-01
      • 2014-09-16
      • 1970-01-01
      相关资源
      最近更新 更多