Skip to main content

XtraReport() Constructor

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

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v23.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public XtraReport()

Remarks

The constructor initializes localizable properties with values fetched from those items in the XtraReport.LocalizationItems collection that match the language of the current thread culture.

Example

The following code sample creates a new object data source, creates a report with the XRLabel control at runtime, and binds the label to data.

For information on supported data sources, review the following article: Bind Reports to Data.

result-static-report-runtime

using System.Collections.Generic;
using System.Drawing;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...
    public class ReportCreator {
        class Employee {
            public string Name { get; set; }
        }
        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;
        }
        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" }
            };
        }
        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;
        }
        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;
        }
    }

The following code snippets (auto-collected from DevExpress Examples) contain references to the XtraReport() constructor.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also