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

SnapControl.SnapMailMergeRecordFinished Event

Occurs after data field merging has finished.

Namespace: DevExpress.Snap

Assembly: DevExpress.Snap.v18.2.dll

Declaration

public event SnapMailMergeRecordFinishedEventHandler SnapMailMergeRecordFinished

Event Data

The SnapMailMergeRecordFinished event's data class is SnapMailMergeRecordFinishedEventArgs. The following properties provide information specific to this event:

Property Description
Cancel Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
Document Returns the document that is being merged.
RecordDocument Provides access to the document created for a single record after the fields are processed.
RecordIndex Returns the data record index.

Remarks

Handle the SnapMailMergeRecordFinished event to perform any actions after the process of field merging has finished. For example, you can access the data source collection of a single record document using the SnapDocument.DataSources property of the SnapDocument object accessed via the SnapMailMergeRecordFinishedEventArgs.RecordDocument property. If you try to delete or modify the main data source being used for the mail-merge process (i.e., the data source assigned to the DataSource and DataSourceName properties of the SnapMailMergeVisualOptions object), an InvalidOperationException will be thrown.

Note also that when a mail merge is performed in the user interface, the SnapMailMergeRecordFinished event can be raised asynchronously, requiring use of the SnapControl‘s InvokeRequired property in the event handler to determine if it is necessary to call the SnapControl.Invoke method to execute a delegate in a thread that owns the control.


void snapControl1_SnapMailMergeActiveSnapMailMergeRecordFinished(object sender, SnapMailMergeRecordFinishedEventArgs e)
{
    Action d = delegate {
        // Add a method to handle the event.
    };
    if (snapControl1.InvokeRequired)
        snapControl1.Invoke(d);
    else
        d();
}

Example

This code snippet illustrates how to add text to the document generated by the SnapDocumentServer.SnapMailMerge method for the particular data record with index = 3.

static void server_SnapMailMergeRecordFinished(object sender, SnapMailMergeRecordFinishedEventArgs e)
{
    if (e.RecordIndex == 3)
    e.RecordDocument.AppendText("This is the third data record.\r\n");
}
See Also