使用场景,分组统计产品数量 ,产品列每行都会重复出现相同的产品名,于是把此列所有相同内容的行的单元格合并成一个单元格,一些人觉得这样看的方便.

不读文档一头雾水,试了很多次都没效果,看了文档发现非常简单.

demo例子中没有,在官网中找到一个案例

https://docs.devexpress.com/XtraReports/120027/detailed-guide-to-devexpress-reporting/use-report-controls/use-tables/manipulate-table-elements

https://github.com/DevExpress-Examples/reporting-winforms-process-duplicate-values/blob/23.1.2%2B/Images/screenshot.gif

public void NoMerge()
            {
                this.ShowPreviewDialog();
            }
            // Merge duplicate values of the XRControl.Tag property.
            public void MergeByTag()
            {
                ExpressionBinding expressionBinding = new ExpressionBinding("BeforePrint", "Tag", "ToStr([SupplierID]) + '_' + ToStr([CategoryID])");
                this.xrTableCell2.ExpressionBindings.Add(expressionBinding);
                this.xrTableCell2.ProcessDuplicatesMode = ProcessDuplicatesMode.Merge;
                this.xrTableCell2.ProcessDuplicatesTarget = DevExpress.XtraReports.UI.ProcessDuplicatesTarget.Tag;
                this.ShowPreviewDialog();
            }
            // Merge duplicate values of a report control's data.
            public void MergeByValue()
            {
                ExpressionBinding expressionBinding = new ExpressionBinding("BeforePrint", "Text", "[CategoryName]");
                this.xrTableCell2.ExpressionBindings.Add(expressionBinding);
                this.xrTableCell2.ProcessDuplicatesMode = ProcessDuplicatesMode.Merge;
                this.xrTableCell2.ProcessDuplicatesTarget = DevExpress.XtraReports.UI.ProcessDuplicatesTarget.Value;
                this.ShowPreviewDialog();
            }

demo内是代码实现的 ,这可能与你的项目展示不太一样.

而简单的方式是,右键单元格属性 

ProcessDuplicatesMode = ProcessDuplicatesMode.Merge;

 

posted on 2024-10-17 09:48  小石头的一天  阅读(2)  评论(0编辑  收藏  举报