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

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.2.dll

Declaration

public IList Components { get; }
Public ReadOnly Property Components As IList

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.

Examples

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;
}
See Also