餐饮加盟资讯
当前位置:  首页 > 创业资讯 > 餐饮加盟资讯 > xrbrand,xrbrand护手霜
xrbrand,xrbrand护手霜
2022-02-06 19:37 来源: 今日头条

xrbrand,xrbrand护手霜

使用场景

今天接到需求说,要把报表同一列值相同的做合并,效果如下图2。由于对XtraReport不熟悉,了解官网后,终于找到答案。怎么用?官网还提供了demo代码。

「XtraReport报表」单元格合并

效果图

「XtraReport报表」单元格合并

图1.原来的样子

「XtraReport报表」单元格合并

图2.合并单元格后的样子

关键代码

tc1.ProcessDuplicatesMode = ProcessDuplicatesMode.Merge; tc1.ProcessDuplicatesTarget = ProcessDuplicatesTarget.Value;

完整代码

using System;using System.Drawing;using System.Collections;using System.ComponentModel;using DevExpress.XtraReports.UI;using System.Collections.Generic;namespace WPFXtraReportMergeCells{ public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport { public XtraReport1() { InitializeComponent(); InsertDataIntoTable(); } private void InsertDataIntoTable() { List<Car> _cars = Car.getCars(); this.DataSource = _cars; xrTable1.BeginInit(); xrTable1.Borders = DevExpress.XtraPrinting.BorderSide.All; Single col1width = 216.67F; Single col2width = 216.67F; Single col3width = 216.67F; xrTableCell1.WidthF = col1width; xrTableCell1.Text = "Brand"; xrTableCell2.WidthF = col2width; xrTableCell2.Text = "Model"; xrTableCell3.WidthF = col3width; xrTableCell3.Text = "Reg. no."; xrTable1.EndInit(); XRTable table = new XRTable(); table.Borders = DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Right; Detail.Controls.Add(table); table.BeginInit(); XRTableRow tr = new XRTableRow(); XRTableCell tc1 = new XRTableCell(); tc1.WidthF = col1width; tc1.ProcessDuplicatesMode = ProcessDuplicatesMode.Merge; tc1.ProcessDuplicatesTarget = ProcessDuplicatesTarget.Value; tc1.DataBindings.Add(new XRBinding("Text", _cars, "Brand")); tr.Cells.Add(tc1); XRTableCell tc2 = new XRTableCell(); tc2.WidthF = col2width; tc2.DataBindings.Add(new XRBinding("Text", _cars, "Model")); tr.Cells.Add(tc2); XRTableCell tc3 = new XRTableCell(); tc3.WidthF = col3width; tc3.DataBindings.Add(new XRBinding("Text", _cars, "Regno")); tr.Cells.Add(tc3); table.Rows.Add(tr); table.AdjustSize(); table.EndInit(); } public class Car { public int Id { get; set; } public string Brand { get; set; } public string Model { get; set; } public string Regno { get; set; } public static List<Car> getCars() { List<Car> list = new List<Car>(); list.Add(new Car { Id = 1, Brand = "Ford", Model = "Fiesta", Regno = "XZ 11 123" }); list.Add(new Car { Id = 2, Brand = "Ford", Model = "Focus", Regno = "XZ 11 124" }); list.Add(new Car { Id = 3, Brand = "Ford", Model = "Mondeo", Regno = "XZ 11 125" }); list.Add(new Car { Id = 4, Brand = "VW", Model = "UP", Regno = "XZ 11 126" }); list.Add(new Car { Id = 5, Brand = "VW", Model = "Polo", Regno = "XZ 11 127" }); list.Add(new Car { Id = 6, Brand = "VW", Model = "Golf", Regno = "XZ 11 128" }); list.Add(new Car { Id = 7, Brand = "VW", Model = "Passat", Regno = "XZ 11 129" }); list.Add(new Car { Id = 8, Brand = "Toyota", Model = "Aygo", Regno = "XZ 11 130" }); list.Add(new Car { Id = 9, Brand = "Toyota", Model = "Yaris", Regno = "XZ 11 131" }); list.Add(new Car { Id = 10, Brand = "Toyota", Model = "Avensis", Regno = "XZ 11 132" }); return list; } } }}

官网

https://supportcenter.devexpress.com/ticket/details/t579011/merge-table-cells-in-a-table-created-in-code

下一篇:返回列表 下一篇:高级男装,高级男装品牌
资讯推荐
猜你喜欢

Copyright © 36加盟网

全国免费服务热线:130*1234567

友情提示:投资有风险,咨询请细致,以便成功加盟。

我们立即与您沟通

(提交后,企业招商经理马上给您回拨)

获取创业资料
手机号码认证(验证后可获取所有创业资料)