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

ExportController.ExportActionItemsCreated Event

Occurs after the Export Action’s ChoiceActionBase.Items collection has been populated.

Namespace: DevExpress.ExpressApp.SystemModule

Assembly: DevExpress.ExpressApp.v18.2.dll

Declaration

public event EventHandler<EventArgs> ExportActionItemsCreated

Event Data

The ExportActionItemsCreated event's data class is EventArgs.

Remarks

By default, the Export Action’s Items collection is populated based on the IExportable.SupportedExportFormats list of the Controller’s ExportController.Exportable editor. To customize the Items collection after it’s been populated, handle the ExportActionItemsCreated event. Note that the exporter used by default can only export data to the formats specified by the ExportTarget enumeration. So, the Action’s Items must be of the ExportTarget type only, if you use the default export.

Note

If the control of the Controller’s ExportController.Exportable Editor doesn’t implement the IPrintable interface or the Exportable Editor is not specified, the Export Action’s Items collection remains empty, the ExportActionItemsCreated event is not raised and the Export Action is not activated.

The following code demonstrates how to place the required item to the first place in the Export Action’s Items collection:

using DevExpress.ExpressApp.SystemModule;
using DevExpress.XtraPrinting;
//...
public partial class MyExportViewController : ViewController {
    public MyExportViewController() {
        InitializeComponent();
        TargetViewType = ViewType.ListView;
    }
    private ExportController exportController;
    protected override void OnActivated() {
        base.OnActivated();
        exportController = Frame.GetController<ExportController>();
        if (exportController != null) {
            exportController.ExportActionItemsCreated += 
                new EventHandler<EventArgs>(exportController_ExportActionItemsCreated);
        }
    }
    void exportController_ExportActionItemsCreated(object sender, EventArgs e) {
        if (((ExportTarget)exportController.ExportAction.Items.FirstActiveItem.Data) != 
        ExportTarget.Xls) {
            ChoiceActionItem item = exportController.ExportAction.Items.Find(ExportTarget.Xls);
            exportController.ExportAction.Items.Remove(item);
            exportController.ExportAction.Items.Insert(0, item);
        }
    }
    protected override void OnDeactivated() {
        base.OnDeactivated();
        if (exportController != null) {
            exportController.ExportActionItemsCreated -= 
               new EventHandler<EventArgs>(exportController_ExportActionItemsCreated); 
        }
    }
}
See Also