xtrareports-devexpress-dot-xtrareports-dot-userdesigner-0e6bef45.md
Specifies the state of the report in the End-User Designer.
Namespace : DevExpress.XtraReports.UserDesigner
Assembly : DevExpress.XtraReports.v25.2.Extensions.dll
NuGet Package : DevExpress.Win.Reporting
public enum ReportState
Public Enum ReportState
| 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.
|
The following properties accept/return ReportState values:
This enumeration is used by the XRDesignPanel.ReportState property.
This example shows how to override the SaveFile and OpenFile commands in the End-User Report Designer.
using System;
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);
// Override the Open Command.
mdiController.AddCommandHandler(new OpenCommandHandler());
// 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;
// Override the Save Command.
panel.AddCommandHandler(new SaveCommandHandler(panel));
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraReports.UserDesigner
Namespace CustomSavingEUD
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
' Create an MDI (multi-document interface) controller instance.
Private mdiController As XRDesignMdiController
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
' Create a design form and get its MDI controller.
Dim form As New XRDesignForm()
mdiController = form.DesignMdiController
' Handle the DesignPanelLoaded event of the MDI controller,
' to override the SaveCommandHandler for every loaded report.
AddHandler mdiController.DesignPanelLoaded, AddressOf mdiController_DesignPanelLoaded
'Override the Open Command.
mdiController.AddCommandHandler(New OpenCommandHandler())
' Open an empty report in the form.
mdiController.OpenReport(New XtraReport1())
' Show the form.
form.ShowDialog()
If mdiController.ActiveDesignPanel IsNot Nothing Then
mdiController.ActiveDesignPanel.CloseReport()
End If
End Sub
Private Sub mdiController_DesignPanelLoaded(ByVal sender As Object, ByVal e As DesignerLoadedEventArgs)
Dim panel As XRDesignPanel = DirectCast(sender, XRDesignPanel)
panel.AddCommandHandler(New SaveCommandHandler(panel))
End Sub
End Class
End Namespace
The following code shows the Save and Open command handlers that implement the ICommandHandler interface:
using DevExpress.XtraReports.UserDesigner;
public class SaveCommandHandler : ICommandHandler {
XRDesignPanel panel;
public SaveCommandHandler(XRDesignPanel panel) {
this.panel = panel;
}
public void HandleCommand(ReportCommand command,
object[] args) {
// Save the report.
Save();
}
public bool CanHandleCommand(ReportCommand command,
ref bool useNextHandler) {
useNextHandler = !(command == ReportCommand.SaveFile ||
command == ReportCommand.SaveFileAs);
return !useNextHandler;
}
void Save() {
// Write your custom method here.
// ...
// Example:
panel.Report.SaveLayout("report1.repx");
// Prevent the "Report has been changed" dialog from being shown.
panel.ReportState = ReportState.Saved;
}
}
using System.Windows.Forms;
using DevExpress.XtraReports.UserDesigner;
public class OpenCommandHandler : ICommandHandler {
public OpenCommandHandler() {
}
public void HandleCommand(ReportCommand command,
object[] args) {
switch (command) {
case ReportCommand.OpenFile:
Open();
break;
}
}
public bool CanHandleCommand(ReportCommand command,
ref bool useNextHandler) {
useNextHandler = !(command == ReportCommand.OpenFile);
return !useNextHandler;
}
void Open() {
MessageBox.Show("Open");
}
}
Imports DevExpress.XtraReports.UserDesigner
Public Class SaveCommandHandler
Implements ICommandHandler
Private panel As XRDesignPanel
Public Sub New(ByVal panel As XRDesignPanel)
Me.panel = panel
End Sub
Public Sub HandleCommand(ByVal command As ReportCommand, ByVal args() As Object) Implements ICommandHandler.HandleCommand
' Save the report.
Save()
End Sub
Public Function CanHandleCommand(ByVal command As ReportCommand, ByRef useNextHandler As Boolean) As Boolean Implements ICommandHandler.CanHandleCommand
useNextHandler = Not (command = ReportCommand.SaveFile OrElse command = ReportCommand.SaveFileAs OrElse command = ReportCommand.Closing)
Return Not useNextHandler
End Function
Private Sub Save()
' Write your custom method here.
' ...
' EXample:
panel.Report.SaveLayout("report1.repx")
' Prevent the "Report has been changed" dialog from being shown.
panel.ReportState = ReportState.Saved
End Sub
End Class
Imports DevExpress.XtraReports.UserDesigner
Public Class OpenCommandHandler
Implements ICommandHandler
Public Sub New()
End Sub
Public Sub HandleCommand(ByVal command As ReportCommand, ByVal args() As Object) Implements ICommandHandler.HandleCommand
Select Case command
Case ReportCommand.OpenFile
Open()
End Select
End Sub
Public Function CanHandleCommand(ByVal command As ReportCommand, ByRef useNextHandler As Boolean) As Boolean Implements ICommandHandler.CanHandleCommand
useNextHandler = Not (command = ReportCommand.OpenFile)
Return Not useNextHandler
End Function
Private Sub Open()
MessageBox.Show("Open")
End Sub
End Class
For information on how to customize the WinForms End-User Report Designer, review the following help topic: WinForms End-User Report Designer API and Customization.
See Also