DevExpress GridView 行颜色

问题描述 投票:0回答:4

这里有人知道如何在 WinForms 上使用 DevExpress GridView 完成这种行吗?

winforms gridview devexpress
4个回答
0
投票

我建议您阅读该主题的文档:自定义各个行和单元格的外观

您可以使用多种方式做到这一点:

  1. 自定义外观
  2. 使用GridView.CustomDrawCell事件

可以处理GridView.RowStyle事件来自定义外观 GridViews 中的单个行。自定义特定单元格的 外观,改为处理 GridView.RowCellStyle 事件。这 GridView.RowStyle 事件在 GridView.RowCellStyle 事件之前触发。

例子:

using DevExpress.XtraGrid.Views.Grid;

private void gridView1_RowStyle(object sender, 
DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e) {
   GridView View = sender as GridView;
   if(e.RowHandle >= 0) {
      string category = View.GetRowCellDisplayText(e.RowHandle, View.Columns["Category"]);
      if(category == "Beverages") {
         e.Appearance.BackColor = Color.Salmon;
         e.Appearance.BackColor2 = Color.SeaShell;
      }            
   }
}

参考文献:
在 DevExpress GridView 上更改行颜色

希望这有帮助..


0
投票

你点击GridView然后点击Theme,你可以从中选择


0
投票

以下是您在窗体中的 DataGridView 控件中的操作方式。我想应该是相似的,自从我上次使用 DevExpress 以来已经有一段时间了。但是你应该仔细阅读 DevExpress 的文档,因为所有组件都有很好的文档记录。

foreach (DataGridViewRow row in dgInformation.Rows)
{
    if (some criteria here == 1234)
    {
        row.DefaultCellStyle.BackColor = Color.Goldenrod;
    }
}

0
投票

尝试以下操作:

gridView.EnableAppearanceEvenRow = true;

或:

gridView.EnableAppearanceOddRow = true;
© www.soinside.com 2019 - 2024. All rights reserved.