The devexpress Master/Slave table is divided by a group of less than one page into one page. This record

Source: Internet
Author: User

This article mainly describes the master and slave tables of the dev report. Each group of master and slave tables is displayed on one page. When a group exceeds one page, only the first group is displayed on the second page.

1. Set the chart for each report

Simple design drawing above

Ii. Background code

Report Page code

Public partial class xtrareport1: devexpress. xtrareports. UI. xtrareport {public xtrareport1 () {initializecomponent ();} /// <summary> /// set the data source of the master/Slave table /// </Summary> /// <Param name = "reportdata"> </param> Public void setreportdatasource (dataset reportdata) {// It is recommended that you create a copy to modify the internal attributes of the dataset. Dataset DS = reportdata. Copy (); // create a copy // important !!! Bind a primary key field to the group (groupheader) // This table is grouped by the business order number groupfield gf = new groupfield ("ID", xrcolumnsortorder. ascending); groupheader1.groupfields. add (GF); // create a primary-foreign key relationship for the dataset datacolumn parentcolumn = Ds. tables ["T1"]. columns ["ID"]; datacolumn childcolumn = Ds. tables ["T2"]. columns ["ID"]; datarelation R1 = new datarelation ("R1", parentcolumn, childcolumn); DS. relations. add (R1); // bind the data source of the master table this. datamember = "T1"; this. datasource = Ds; this. xrlabel2.databindings. add ("text", DS, "t1.id"); // bind the data source of the detail table this. detailreport. datamember = "R1"; this. detailreport. datasource = Ds; this. xrlabel5.databindings. add ("text", DS, "r1.id"); this. xrlabel6.databindings. add ("text", DS, "r1.name"); xrlabel3.databindings. add ("text", DS, "r1.id"); // bind subtotal (total amount of the current document) xrlabel4.databindings. add ("text", DS, "r1.id"); // bind subtotal (total amount of the current document )}}

Front-End call code

Private void simplebutton#click (Object sender, eventargs e) {xtrareport1 Xtra = new xtrareport1 (); dataset DS = new dataset (); datatable dt1 = new datatable ("T1"); dt1.columns. add ("ID", type. getType ("system. string "); datatable dt2 = new datatable (" T2 "); dt2.columns. add ("ID", type. getType ("system. string "); dt2.columns. add ("name", type. getType ("system. string "); For (INT I = 0; I <3; I ++) {datarow dt1dr = dt1.newrow (); dt1dr [" ID "] = I. tostring (); dt1.rows. add (dt1dr); For (Int J = 0; j <39; j ++) {datarow dt2dr = dt2.newrow (); dt2dr ["ID"] = I. tostring (); dt2dr ["name"] = J. tostring () + "test"; dt2.rows. add (dt2dr) ;}} Ds. tables. add (dt1); DS. tables. add (dt2); Xtra. setreportdatasource (DS); Xtra. showpreviewdialog ();}

The Master/Slave table code is as follows:

Design focus

1. Add a paging Header

2. Build Master/Slave table data

3. Set the detailreport pagebreak to afterband.

This example can be used to print documents and connect multiple documents as needed!

Download Sample Code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.