惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy International News Feed
WordPress大学
WordPress大学
Security Latest
Security Latest
Cyberwarzone
Cyberwarzone
K
Kaspersky official blog
Cisco Talos Blog
Cisco Talos Blog
Microsoft Security Blog
Microsoft Security Blog
G
GRAHAM CLULEY
N
News | PayPal Newsroom
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog
美团技术团队
J
Java Code Geeks
I
Intezer
The Cloudflare Blog
SecWiki News
SecWiki News
S
Secure Thoughts
Microsoft Azure Blog
Microsoft Azure Blog
V2EX - 技术
V2EX - 技术
C
Cyber Attacks, Cyber Crime and Cyber Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Spread Privacy
Spread Privacy
D
DataBreaches.Net
S
Security Affairs
Help Net Security
Help Net Security
S
Securelist
F
Full Disclosure
C
Check Point Blog
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
博客园_首页
G
Google Developers Blog
Google Online Security Blog
Google Online Security Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Hacker News: Front Page
L
LINUX DO - 热门话题
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LangChain Blog

博客园 - 木人(我现在不是老大)

ERP系统的专业化发展趋势 讨厌的real和float数据 Svcutil使用点滴 windows server2003企业版64位安装sql server2008企业版64位 水晶报表使用push模式(2) 水晶报表使用push模式(1) SQL SERVER2000存储过程调试 读书笔记 UltraGrid(15) 读书笔记 UltraGrid(14) 读书笔记 UltraGrid(12) 读书笔记 UltraGrid(11) 读书笔记 UltraGrid(10) 读书笔记 UltraGrid(9) 读书笔记 UltraGrid(8) 读书笔记 UltraGrid(7) 读书笔记 UltraGrid(6) 读书笔记 UltraGrid(5) 读书笔记 UltraGrid(4) 读书笔记 UltraGrid(3)
读书笔记 UltraGrid(16)
木人(我现在不是老大) · 2012-02-25 · via 博客园 - 木人(我现在不是老大)

单元格合并
当使用grid列示数据时,如果某一行某列数据和上一行的对应列数据相同时,我们想把该列的显示隐含。
所有band中的所有列。
this.ultraGrid1.DisplayLayout.Override.MergedCellStyle = MergedCellStyle.Always
其值还可以是:
OnlyWhenSorted:只在排序时候合并
Never:从不合并

也可以针对具体的列来设置,如:
this.ultraGrid1.DisplayLayout.Bands[1].Columns["SpecWth"].MergedCellStyle = MergedCellStyle.Never;
合并可以按文本相同或者值相同,如:
this.ultraGrid1.DisplayLayout.Bands[1].Columns["SpecWth"].MergedCellEvaluationType = MergedCellEvaluationType.MergeSameText;

但有时这种合并还是不能满足我们的要求,那我们可以自定义条件合并即可。
实现如下:
public class CustomMergedCellEvaluator : IMergedCellEvaluator
{
        UltraGridColumn[] ugcs;
        public CustomMergedCellEvaluator(UltraGridColumn[] keys)
        {
            this.ugcs = keys;
        }

        public bool ShouldCellsBeMerged(UltraGridRow row1, UltraGridRow row2, UltraGridColumn column)
        {
            bool keyIsSame = KeyIsSame(row1, row2, this.ugcs);
            if (keyIsSame == true)
                return row1.Cells[column].Value.ToString () == row2.Cells[column].Value.ToString();
            else
                return false;
        }

        private bool KeyIsSame(UltraGridRow row1, UltraGridRow row2, UltraGridColumn[] keys)
        {
           //定义合并的逻辑
            return keyIsSame;
        }
}

这时我们在column中设置如下,即可按我们的条件合并了。
ustomMergedCellEvaluator cmce = new CustomMergedCellEvaluator(new UltraGridColumn[]{ultraGrid1.DisplayLayout.Bands[1].Columns[0],ultraGrid1.DisplayLayout.Bands[1].Columns[1]});
column.MergedCellEvaluator = cmce;
column.MergedCellStyle = MergedCellStyle.Always;
column.MergedCellEvaluationType = MergedCellEvaluationType.MergeSameText;
其实现也就如此的简单。