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

SaveComponentsEventArgs Class

Provides data for the XtraReport.SaveComponents event.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

Declaration

public class SaveComponentsEventArgs :
    EventArgs
Public Class SaveComponentsEventArgs
    Inherits EventArgs

Remarks

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

Note

SaveComponentsEventArgs objects are automatically created, initialized and passed to the XtraReport.SaveComponents event handlers.

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

Inheritance

Object
EventArgs
SaveComponentsEventArgs
See Also