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

SaveComponentsEventArgs.Components Property

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

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

NuGet Packages: DevExpress.Reporting.Core, DevExpress.WindowsDesktop.Core

Declaration

public IList Components { get; }

Property Value

Type Description
IList

An object, which implements the IList interface, representing the components to be saved.

Remarks

The XtraReport.SaveComponents event occurs when a report is saved to an REPX file. This event allows you to manually decide which compoents should be stored into a report definition file, and which aren’t. For example, to prevent a particular component from being saved to an REPX file, simply remove this component from the Components collection in the XtraReport.SaveComponents event handler.

Example

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 
        EventHandler<SaveComponentsEventArgs>(report_SaveComponents);
    report.ShowDesignerDialog();
}

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

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;
            break;
        } 
    }

    return idx;
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Components 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