【问题标题】:C# change text color on one cell in gridC# 更改网格中一个单元格上的文本颜色
【发布时间】:2017-06-29 06:36:49
【问题描述】:

我有一个网格,我想让一个随机单元格成为某种颜色。如何获取代码以将单元格中的这一文本着色为黄色。到目前为止,这是我在方法中所拥有的

 private void LunchOnly_Click(object sender, RoutedEventArgs e)
    {
        ChangeFromMain();
        LunchGrid.Visibility = Visibility.Visible;
        int chosen = RandoLunch(15);
        int gridrow = (chosen / 2);
        int gridcol = (chosen % 2);
    }

【问题讨论】:

  • 你的意思是DataGrid吗?

标签: c# visual-studio xaml colors grid


【解决方案1】:
row.Cells[cell].Style = new DataGridViewCellStyle() { BackColor = Color.Yellow };

“cell”是单元格的索引。您可以使用字符串或整数索引。

【讨论】:

    猜你喜欢
    • 2020-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-21
    相关资源
    最近更新 更多