Skip to main content
A newer version of this page is available. .

Create a Report in Code

  • 2 minutes to read

The following steps describe how to create a report in code:

  1. Create an instance of the XtraReport class or implement an XtraReport class descendant.
  2. Assign a data source to the report: specify the DataSource and DataMember properties.
  3. Create bands and add them to the report’s Bands collection (the DetailBand is mandatory).
  4. Create report controls and add them to the report’s bands.
  5. Add styles to report elements.

After the report layout is complete, you can generate the report document and display it in a Print Preview.

Examples

The following examples illustrate how to generate specific report types in code:

The following topics describe the report object model and events:

Troubleshooting

If a runtime-generated report does not work as expected or you want to know how to implement a particular feature in code, follow these steps:

  1. Use the report’s SaveLayoutToXml method to save the generated report as a REPX file.
  2. Add a new report to your .NET Framework project, expand the report’s smart tag, and import the generated REPX file.

    Import a Report

  3. Specify the report’s data source and preview the changes.

  4. Modify the report layout.
  5. The XtraReport.Designer.cs or XtraReport.Designer.vb file contains code that generates the report. Use this code in your application to get a similar result.
See Also