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

XtraReport.SaveComponents Event

Occurs when a report is saved to an REPX file and allows you to manually decide which components should be stored into a report definition file, and which aren't.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.2.dll


public event EventHandler<SaveComponentsEventArgs> SaveComponents
Public Event SaveComponents As EventHandler(Of SaveComponentsEventArgs)

Event Data

The SaveComponents event handler receives an argument of the SaveComponentsEventArgs type. The following properties provide information specific to this event.

Property Description
Components Provides access to the list of components that will be saved along with a report's layout into a REPX file.


Handle the SaveComponents event to customize the list of components to be saved along with a report to an REPX report definition file. To do this, use the SaveComponentsEventArgs.Components property. Adding a particular component to this list will force its serialization to an REPX file, while to prevent a particular component from being saved, you simply need to remove it from the Components list.

The SaveComponents event fires only when a report is saved to a report definition file (REPX) using the CodeDOM serialization (e.g., on calling the XtraReport.SaveLayout method). This is why, this event is not raised on saving a report in the End-User Report Designer where XML serialization is used by default.

For more information on handling events, see Events and Delegates in MSDN.


This example demonstrates how to exclude a DataSet, along with its TableAdapter, when saving a report definition to an REPX file. To do this, it is necessary to handle the XtraReport.SaveComponents event, and customize its SaveComponentsEventArgs.Components collection.

using System;
using System.ComponentModel;
using System.Data;
using System.Windows.Forms;
using System.Collections;
using DevExpress.XtraReports.UI;
// ...

private void Form1_Load(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();
    report.SaveComponents += new 

void report_SaveComponents(object sender, SaveComponentsEventArgs e) {
    int tableAdapterIdx = GetItemIndex(e.Components, typeof(Component));
    if (tableAdapterIdx >= 0)
    int dsIdx = GetItemIndex(e.Components, typeof(DataSet));
    if (dsIdx >= 0)

private static int GetItemIndex(IList components, Type targetType) {
    int idx = -1;
    for (int i = 0; i < components.Count; i++) {
        if (components[i].GetType().BaseType == targetType) {
            idx = i;

    return idx;
See Also