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

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
V2EX - 技术
V2EX - 技术
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
Forbes - Security
Forbes - Security
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
Apple Machine Learning Research
Apple Machine Learning Research
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Webroot Blog
Webroot Blog
W
WeLiveSecurity
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
Last Week in AI
Last Week in AI
月光博客
月光博客
H
Help Net Security
PCI Perspectives
PCI Perspectives
Security Archives - TechRepublic
Security Archives - TechRepublic
Hugging Face - Blog
Hugging Face - Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
有赞技术团队
有赞技术团队
T
Troy Hunt's Blog
Google DeepMind News
Google DeepMind News
Hacker News: Ask HN
Hacker News: Ask HN
Microsoft Security Blog
Microsoft Security Blog
N
News and Events Feed by Topic
Project Zero
Project Zero
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
LangChain Blog
P
Privacy & Cybersecurity Law Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
I
Intezer
H
Hacker News: Front Page
Recent Announcements
Recent Announcements
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园 - Franky
T
Threat Research - Cisco Blogs
Spread Privacy
Spread Privacy
博客园 - 【当耐特】
美团技术团队
Schneier on Security
Schneier on Security
D
Docker
Scott Helme
Scott Helme
L
LINUX DO - 最新话题
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
aimingoo的专栏
aimingoo的专栏
L
Lohrmann on Cybersecurity

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

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;
其实现也就如此的简单。