DevExpress GridView行颜色 [英] DevExpress GridView Row Color

查看:126
本文介绍了DevExpress GridView行颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Anyone here knows how to accomplish this kind of rows using DevExpress GridView on WinForms?

推荐答案

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

I suggest you to go through documentation for the topic: Customizing Appearances of Individual Rows and Cells.

您可以使用多种方式执行此操作:

You can do this using various ways:

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

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

The GridView.RowStyle event can be handled to customize the appearance of individual rows in GridViews. To customize a specific cell's appearance, handle the GridView.RowCellStyle event instead. The GridView.RowStyle event fires before the GridView.RowCellStyle event.

示例:

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上更改行颜色

希望这项帮助.

这篇关于DevExpress GridView行颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆