The requested page is not available for the requested platform. You are viewing the content for Default platform.

XtraReport() Constructor

Initializes a new instance of the XtraReport class with the default settings.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

Declaration

public XtraReport()
Public Sub New

Examples

The code sample below creates a simple data-bound report.

result-static-report-runtime

using System.Collections.Generic;
using System.Drawing;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;

// ...

class Employee {
    public string Name { get; set; }
}

// Create a report and assign bands to it.
public static XtraReport CreateReport() {
    XtraReport report = new XtraReport() {
        DataSource = CreateDataSource(),
        StyleSheet = {
            new XRControlStyle() { Name = "Title", Font = new Font("Tahoma", 20f, FontStyle.Bold) },
            new XRControlStyle() { Name = "Normal", Font = new Font("Tahoma", 10f), Padding = new PaddingInfo(2, 2, 0, 0) },
        }
    };
    var reportHeaderBand = CreateReportHeader("List of employees");
    var detailBand = CreateDetail("[Name]");
    report.Bands.AddRange(new Band[] { reportHeaderBand, detailBand });
    return report;
}

// Create an employees list to serve as the report's data source.
static List<Employee> CreateDataSource() {
    return new List<Employee>() {
        new Employee() { Name = "Nancy Davolio" },
        new Employee() { Name = "Andrew Fuller" },
        new Employee() { Name = "Janet Leverling" },
        new Employee() { Name = "Margaret Peacock" },
        new Employee() { Name = "Steven Buchanan" },
        new Employee() { Name = "Michael Suyama" },
        new Employee() { Name = "Robert King" },
        new Employee() { Name = "Laura Callahan" },
        new Employee() { Name = "Anne Dodsworth" }
    };
}

// Create a Report Header band and add a report title label to it.
static ReportHeaderBand CreateReportHeader(string title) {
    ReportHeaderBand reportHeaderBand = new ReportHeaderBand() {
        HeightF = 50
    };
    XRLabel titleLabel = new XRLabel() {
        Text = title,
        BoundsF = new RectangleF(0, 0, 300, 30),
        StyleName = "Title"
    };
    reportHeaderBand.Controls.Add(titleLabel);
    return reportHeaderBand;
}

// Create a Detail band and add an employee name label to it.
static DetailBand CreateDetail(string expression) {
    DetailBand detailBand = new DetailBand() {
        HeightF = 25
    };
    XRLabel detailLabel = new XRLabel() {
        ExpressionBindings = { new ExpressionBinding("Text", expression) },
        BoundsF = new RectangleF(0, 0, 300, 20),
        StyleName = "Normal"
    };
    detailBand.Controls.Add(detailLabel);
    return detailBand;
}
See Also