DashboardViewer.CustomExport Event
Allows you to customize the exported document.
Namespace: DevExpress.DashboardWin
Assembly: DevExpress.Dashboard.v18.2.Win.dll
Declaration
Event Data
The CustomExport event's data class is CustomExportEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
ExportAction | Gets the export action performed by an end-user. Inherited from CustomExportBaseEventArgs. |
ExportMode | Gets the document export mode. Inherited from CustomExportBaseEventArgs. |
ImageExportOptions | Gets export options related to exporting a dashboard/dashboard item to an image. Inherited from CustomExportBaseEventArgs. |
ImageOptions | Obsolete. Gets export options related to exporting a dashboard/dashboard item to an image. Inherited from CustomExportBaseEventArgs. |
ItemComponentName | Gets the component name of the exported dashboard item. Inherited from CustomExportBaseEventArgs. |
PdfExportOptions | Gets export options related to exporting a dashboard/dashboard item to PDF format. Inherited from CustomExportBaseEventArgs. |
PdfOptions | Obsolete. Gets export options related to exporting a dashboard/dashboard item to PDF format. Inherited from CustomExportBaseEventArgs. |
PrintableComponents | Provides access to a dictionary containing dashboard item names and related PrintableComponents. For internal use. |
PrintPreviewOptions | Gets options related to printing a dashboard/dashboard item using the Print Preview window. Inherited from CustomExportBaseEventArgs. |
Report | Gets the underlying report of the exported document. |
Remarks
The CustomExport event is raised is raised before saving the exported document to the PDF and Image formats, and allows you to customize the underlying report using the CustomExportEventArgs.Report parameter. When handling this event, you can obtain the following information.
- The CustomExportBaseEventArgs.ExportMode allows you to determine whether an entire dashboard or an individual item is exported.
- The CustomExportBaseEventArgs.ExportAction property returns the export action that caused the event.
- The CustomExportBaseEventArgs.PdfExportOptions and CustomExportBaseEventArgs.ImageExportOptions properties allow you to obtain export options corresponding to the format used.
Note
Note that a reference to the DevExpress.XtraReports.v18.2.dll assembly should be added to the project to allow customizing the underlying report (CustomExportEventArgs.Report).
Example
The following example shows how to specify header and footer content of an exported dashboard using the DashboardViewer.CustomExport
event. This event provides access to the underlying report(XtraReport) of the exported document.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-dashboard-how-to-add-custom-information-to-the-exported-dashboard-t466558.
using System.Windows.Forms;
using DevExpress.DashboardCommon;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
namespace WinViewer_CustomExport
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void dashboardViewer1_CustomExport(object sender, CustomExportEventArgs e)
{
XtraReport report = e.Report as XtraReport;
PageHeaderBand headerBand = new PageHeaderBand();
report.Bands.Add(headerBand);
XRPictureBox icon = new XRPictureBox();
icon.Image = Properties.Resources.dxLogo;
icon.HeightF = 50;
icon.WidthF = 300;
headerBand.Controls.Add(icon);
XRLabel customHeader = new XRLabel();
customHeader.Text = "Additioanl Header Text";
customHeader.LeftF = 300;
customHeader.WidthF = 300;
headerBand.Controls.Add(customHeader);
XRPageInfo dateInfo = new XRPageInfo();
dateInfo.PageInfo = PageInfo.DateTime;
dateInfo.Format = "Created at {0:h:mm tt dd MMMM yyyy}";
dateInfo.TopF = 100;
dateInfo.WidthF = 200;
headerBand.Controls.Add(dateInfo);
XRPageInfo userInfo = new XRPageInfo();
userInfo.PageInfo = PageInfo.UserName;
userInfo.Format = "Current User: {0}";
userInfo.TopF = 100;
userInfo.LeftF = 250;
userInfo.WidthF = 200;
headerBand.Controls.Add(userInfo);
PageFooterBand footerBand = new PageFooterBand();
report.Bands.Add(footerBand);
XRPageInfo pageInfo = new XRPageInfo();
pageInfo.Format = "Page {0} of {1}";
footerBand.Controls.Add(pageInfo);
}
}
}