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

XRDesignPanel.ReportState Property

Gets the state of the report currently being edited in the Design Panel.

Namespace: DevExpress.XtraReports.UserDesigner

Assembly: DevExpress.XtraReports.v19.1.Extensions.dll

NuGet Package: DevExpress.Win.Reporting

Declaration

[Browsable(false)]
public ReportState ReportState { get; set; }

Property Value

Type Description
ReportState

A ReportState enumeration value which represents the current state of a report.

Available values:

Name Description
None

The report’s state is not specified.

Opening

The report is in the process of opening.

Opened

The report is open in the End-User Designer.

Changed

At least one component in the report has been modified.

Saved

The report has been saved to a file.

Closing

The report editing session is being closed.

Remarks

Use the ReportState property, to obtain or modify the current state of the report being edited in the XRDesignPanel. For example, after you’ve manually saved a report in the Design Panel, you should set the ReportState property to ReportState.Saved.

Note

In most cases, you don’t need to manually set the value of the ReportState property, because it’s done automatically.

Example

This example demonstrates how to override and customize saving in the End-User Designer. This can be useful, for example, if all the reports in a project should be stored in a database, and are retrieved from the database via a stream, and all of this should be done automatically, without forcing an end-user to do anything but click the Save (or Save As) toolbar button.

In this example, a report will also be automatically saved using the custom saving procedure when an end-user closes the Report Designer. To implement this task, handle the ReportCommand.SaveFile and ReportCommand.SaveFileAs commands (and, if necessary, the ReportCommand.Closing command, as well).

The following code demonstrates how this can be done.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraReports.UserDesigner;

namespace CustomSavingEUD
{
    public partial class Form1 : Form
    {
        public Form1() {
            InitializeComponent();
        }

        // Create an MDI (multi-document interface) controller instance.
        XRDesignMdiController mdiController;

        private void button1_Click(object sender, EventArgs e) {
            // Create a design form and get its MDI controller.
            XRDesignForm form = new XRDesignForm();
            mdiController = form.DesignMdiController;

            // Handle the DesignPanelLoaded event of the MDI controller,
            // to override the SaveCommandHandler for every loaded report.
            mdiController.DesignPanelLoaded +=
                new DesignerLoadedEventHandler(mdiController_DesignPanelLoaded);

            // Open an empty report in the form.
            mdiController.OpenReport(new XtraReport1());

            // Show the form.
            form.ShowDialog();
            if (mdiController.ActiveDesignPanel != null) {
                mdiController.ActiveDesignPanel.CloseReport();
            }
        }
        void mdiController_DesignPanelLoaded(object sender, DesignerLoadedEventArgs e) {
            XRDesignPanel panel = (XRDesignPanel)sender;
            panel.AddCommandHandler(new SaveCommandHandler(panel));
        }

        public class SaveCommandHandler : DevExpress.XtraReports.UserDesigner.ICommandHandler {
            XRDesignPanel panel;

            public SaveCommandHandler(XRDesignPanel panel) {
                this.panel = panel;
            }

            public void HandleCommand(DevExpress.XtraReports.UserDesigner.ReportCommand command,
            object[] args) {
                // Save the report.
                Save();
            }

            public bool CanHandleCommand(DevExpress.XtraReports.UserDesigner.ReportCommand command,
            ref bool useNextHandler) {
                useNextHandler = !(command == ReportCommand.SaveFile ||
                    command == ReportCommand.SaveFileAs);
                return !useNextHandler;
            }

            void Save() {
                // Write your custom saving here.
                // ...

                // For instance:
                panel.Report.SaveLayout("c:\\report1.repx");

                // Prevent the "Report has been changed" dialog from being shown.
                panel.ReportState = ReportState.Saved;
            }
        }
    }
}

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

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