【问题标题】:DevExpress GridView Row ColorDevExpress GridView 行颜色
【发布时间】:2016-06-27 03:09:07
【问题描述】:

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

【问题讨论】:

    标签: winforms gridview devexpress


    【解决方案1】:

    我建议您阅读该主题的文档:Customizing Appearances of Individual Rows and Cells

    您可以通过多种方式做到这一点:

    1. Customizing Appearances
    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;
          }            
       }
    }
    

    参考资料:
    Changing Row Colours on DevExpress GridView

    希望对您有所帮助..

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 您好,感谢您的反馈,但我不是在寻找主题,而是在寻找更改行颜色。
      【解决方案3】:

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

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

      【讨论】:

        猜你喜欢
        • 2013-08-13
        • 2020-03-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-07-26
        • 2014-11-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多