xrbrand,xrbrand護手霜,36創業加盟網給大家帶來詳細的介紹,讓更多的人可以參考:xrbrand,xrbrand護手霜。
今天接到需求說,要把報表同一列值相同的做合并,效果如下圖2。由于對XtraReport不熟悉,了解官網后,終于找到答案。怎么用?官網還提供了demo代碼。
圖1.原來的樣子
圖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
總結:以上內容就是xrbrand,xrbrand護手霜詳細介紹,如果您對創業項目感興趣,可以咨詢客服或者文章下面留言,我們會第一時間給您項目的反饋信息。
我對加盟感興趣,馬上免費通話或留言!
(24小時內獲得企業的快速回復)
我們立即與您溝通
溫馨提示:
1.此次通話將不會產生任何費用, 請放心使用
7x24小時電話咨詢
130*1234567