开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 6358|回复: 4

XtraGrid 单元格 行 颜色设置

[复制链接]

0

精华

40

贡献

32

赞扬

帖子
50
软币
1509
在线时间
73 小时
注册时间
2013-6-9
QQ
发表于 2013-6-28 11:54:21 | 显示全部楼层 |阅读模式
单元格  
private void ConditionsAdjustment()
        {
            DevExpress.XtraGrid.StyleFormatCondition cn;
            cn = new DevExpress.XtraGrid.StyleFormatCondition(FormatConditionEnum.Equal, this.gridView1.Columns["STATUS"], null, "5");

            cn.Appearance.BackColor = Color.YellowGreen;
            this.gridView1.FormatConditions.Add(cn);

        }

        private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
        {
            DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
            if (e.RowHandle >= 0)
            {
                string category = view.GetRowCellDisplayText(e.RowHandle, view.Columns["STATUS"]);
                if (category == "5")
                {
                    e.Appearance.BackColor = Color.YellowGreen;

                }
            }
        }

评分

参与人数 4赞扬 +4 收起 理由
nickcole + 1 感谢分享
yuan135 + 1 Thanks
沙里Jin + 1 赞一个
羽叶 + 1

查看全部评分

回复

使用道具 举报

0

精华

74

贡献

722

赞扬

正版授权组

Rank: 14Rank: 14Rank: 14Rank: 14

帖子
183
软币
3861
在线时间
327 小时
注册时间
2013-6-7
发表于 2013-7-2 10:20:35 | 显示全部楼层
改变整行的颜色, 用第一种方式也可以啊, 只需要对条件格式设置一下运用到整行即可.

DevExpress.XtraGrid.StyleFormatCondition cn;
cn = new DevExpress.XtraGrid.StyleFormatCondition(FormatConditionEnum.Equal, this.gridView1.Columns["STATUS"], null, "5");

cn.ApplyToRow = true;

cn.Appearance.BackColor = Color.YellowGreen;
this.gridView1.FormatConditions.Add(cn);

评分

参与人数 1赞扬 +1 收起 理由
羽叶 + 1

查看全部评分

回复

使用道具 举报

0

精华

0

贡献

0

赞扬

帖子
6
软币
102
在线时间
4 小时
注册时间
2016-5-28
发表于 2016-7-28 10:38:47 | 显示全部楼层
nyfor 发表于 2013-7-2 10:20
改变整行的颜色, 用第一种方式也可以啊, 只需要对条件格式设置一下运用到整行即可.

DevExpress.XtraGrid.S ...

问题是这个事件如何触发呀?
回复

使用道具 举报

0

精华

74

贡献

722

赞扬

正版授权组

Rank: 14Rank: 14Rank: 14Rank: 14

帖子
183
软币
3861
在线时间
327 小时
注册时间
2013-6-7
发表于 2016-8-5 09:19:06 | 显示全部楼层
darling 发表于 2016-7-28 10:38
问题是这个事件如何触发呀?

这不是在Grid的某个事件里边写的,它是一段设置代码.
这段代码你可以放到 Form_Load事件中.
回复

使用道具 举报

0

精华

0

贡献

513

赞扬

帖子
95
软币
1110
在线时间
69 小时
注册时间
2017-8-2
发表于 2024-2-21 17:16:12 | 显示全部楼层
Thanks for Sharing.
回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-5-3 07:47

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表