Use ActiveReport for. net for report development (4)-display Master/Slave tables)

Source: Internet
Author: User

The previous article demonstrates how to extract data from the object set in ActiveReport for. net. This section describes how to use a subreport to display data in a master-slave table.

 

1. when you need to display data in a master-slave table, using subreports can provide great flexibility. Generally, the information of the master table is displayed in detail, if you want to display the master table at the top of each page, you can put it in PageHeader. Then, place the sub-table information in Detail, bind the control in the sub-Report to the data source directly, or extract data from the object set using the method mentioned in the previous article.

2. Use the subreport:

Create a report, and then you can see the SubReport control in the toolbox. Drag and Drop a control to the Detail section and use this control to load the SubReport.

Create a new report named SubReport1, write code in the main report, select the Detail part in the page designer, switch to the event bar in the Properties window, and double-click Format, the Detail_Format event is generated. The following describes the report to be loaded by the subreport control.

3. Because the Detail part is displayed repeatedly, you can only specify a report source once. Here, we follow the example below:

ActiveReport sub = null;

Private void Detail_Format (object sender, System. EventArgs eArgs)

{

If (sub = null)

{

Sub = new ActiveReports2 ();

This. SubReport. Report = sub;

}

}

Define a global subreport and initialize it in the Detail_Format event.

4. You should also note that the subreport should be released and destroyed after it is used. The specific code should be placed in the ReportEnd event of the main report, for example:

Private void ActiveReports1_ReportEnd (object sender, System. EventArgs eArgs)

{

Sub. Document. Dispose ();

Sub. Dispose ();

Sub = null;

}

5. The rest of the following work is to place the control, set the display fields, load the data, and so on. The previous articles are all described.

 

The next article describes how to use ActiveReport for. net to develop a cross report.

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.