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

Invoke a Default End-User Report Designer Form

  • 6 min to read

This tutorial illustrates how to open a report in an End-User Report Designer form

Note

You need a Reporting subscription to use the API described in this tutorial.

Use a Default Design Form

Create a ReportDesignTool class instance with a specified XtraReport (requires referencing the DevExpress.XtraReports.UI namespace) and use any of the following methods to load a report into one of the default End-User Report Designer forms in a WinForms application:

  • Ribbon Report Designer

    The ReportDesignTool.ShowRibbonDesigner and ReportDesignTool.ShowRibbonDesignerDialog methods show a form with a ribbon toolbar.

    Each of these methods has overloads to invoke the Designer form with either the default or custom look and feel settings applied.

    The following code illustrates how to call these methods in the main application form's Load event handler:

    using DevExpress.XtraReports.UI;
    using DevExpress.LookAndFeel;
    // ...
    
    private void Form1_Load(object sender, System.EventArgs e) {
        ReportDesignTool designTool = new ReportDesignTool(new XtraReport1());
    
        // Invoke the Ribbon End-User Report Designer form  
        // and load the report into it.
        designTool.ShowRibbonDesigner();
    
        // Invoke the Ribbon End-User Report Designer form modally 
        // with the specified look and feel settings.
        designTool.ShowRibbonDesignerDialog(UserLookAndFeel.Default);
    }
    

    To make these methods display the End-User Report Designer form with the previous ribbon version, set the static UseOfficeInspiredRibbonStyle property to false at the application's startup.

    static class Program {
        static void Main() {
            DevExpress.XtraReports.Configuration.DesignSettings.Default.UseOfficeInspiredRibbonStyle = false;
            // ... 
        }
    }
    

    default-ribbon-report-designer-form

  • Standard Report Designer

    The ReportDesignTool.ShowDesigner and ReportDesignTool.ShowDesignerDialog methods invoke a form with a standard toolbar.

    default-standard-report-designer-form

    Both methods have overloads to invoke the Designer form with either the default or custom look and feel settings applied.

    using DevExpress.XtraReports.UI;
    using DevExpress.LookAndFeel;
    // ...
    
    private void Form1_Load(object sender, System.EventArgs e) {
        ReportDesignTool designTool = new ReportDesignTool(new XtraReport1());
    
        // Invoke the End-User Report Designer form  
        // and load the report into it. 
        designTool.ShowDesigner();
    
        // Invoke the Print Preview form modally 
        // with the specified look and feel settings.
        designTool.ShowDesignerDialog(UserLookAndFeel.Default);
    }
    
Tip

See Adding a New Report to a WinForms Application to learn how to add a new XtraReport at design time in the Visual Studio.

Use a Specific Design Form

The following examples illustrate how you can open a report in a custom Report Designer form:

  • Ribbon Report Designer

    When creating a custom Report Designer derived from the XRDesignRibbonForm class, you can load a report into it via the XRDesignRibbonForm.OpenReport method.

    using DevExpress.XtraReports.UserDesigner;
    // ...
    
    private void Form1_Load(object sender, System.EventArgs e) {
        // Enables form skins in the application (if required).
        DevExpress.Skins.SkinManager.EnableFormSkins();
        DevExpress.LookAndFeel.LookAndFeelHelper.ForceDefaultLookAndFeelChanged();
    }
    
    private void button1_Click(object sender, System.EventArgs e) {
        // Create an End-User Report Designer form with a ribbon UI.
        XRDesignRibbonForm designForm = new XRDesignRibbonForm();
    
        // Create a new blank report.
        designForm.OpenReport(new XtraReport1());
    
        // Display the Report Designer form.
        //designForm.Show();
    
        // Display the Report Designer form, modally.
        designForm.ShowDialog();
    }
    

    To show the Report Designer form with the previous ribbon version, disable the static UseOfficeInspiredRibbonStyle property at the application's startup.

    Note

    The XRDesignRibbonForm is based on the RibbonForm class and using it in your application requires adding the following libraries to the References list of your project:

    • DevExpress.XtraBars.v19.1
    • DevExpress.XtraEditors.v19.1
  • Standard Report Designer

    When creating a custom Report Designer derived from the XRDesignForm class, you can load a report into it via the XRDesignForm.OpenReport method.

    using DevExpress.XtraReports.UserDesigner;
    // ...
    
    private void button1_Click(object sender, System.EventArgs e) {
        // Create a new End-User Report Designer form.
        XRDesignForm designForm = new XRDesignForm();
    
        // Load a report into the Report Designer.
        designForm.OpenReport(new XtraReport1());
    
        // Display the Report Designer form.
        // designForm.Show();
    
        // Display the Report Designer form, modally.
        designForm.ShowDialog();
    }
    

Use the XRDesignPanel.Report property to access the report displayed in a Report Designer form. To save that report to a file, use the XRDesignPanel.SaveReport method.

using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.UserDesigner;
// ...

private void button1_Click(object sender, System.EventArgs e) {
    // Create a new End-User Report Designer form.
    XRDesignForm designForm = new XRDesignForm();

    // Handle the DesignPanelLoaded event before opening a report in the Report Designer
    designForm.DesignMdiController.DesignPanelLoaded += DesignMdiController_DesignPanelLoaded;

    // Create a new blank report and show it the Report Designer dialog window.
    designForm.OpenReport(new XtraReport1());
    designForm.ShowDialog();
}

public XtraReport report;

void DesignMdiController_DesignPanelLoaded(object sender, DesignerLoadedEventArgs e) {
    // Access the currently opened report.
    report = (sender as XRDesignPanel).Report;

    // Save the report that is currently open to a file.
    (sender as XRDesignPanel).SaveReport(@"D:\\report.repx");
}