SnapMailMergeRecordStartedEventArgs.RecordDocument Property
Provides access to the document created for a single record before the fields are processed.
Namespace: DevExpress.Snap
Assembly: DevExpress.Snap.v21.2.Core.dll
NuGet Package: DevExpress.Snap.Core
Declaration
Property Value
Type | Description |
---|---|
SnapDocument | An object implementing the SnapDocument interface. |
Remarks
Use the RecordDocument property to modify the document before the fields are processed. You can add a new field, modify or remove existing fields to create a different document for a particular record.
Example
This code snippet affects the SNIMAGE field bound to the Picture data field, only for the data record with index = 3. The code enlarges an image two times.
This can be accomplished by iterating over the SubDocument.Fields collection and using the ISnapFieldOwner.ParseField method to find the SnapImage object.
Another way is to perform a text search and replace in the field code range. For this, the document must display field codes (the Field.ShowCodes is true for the required field).
static void server_SnapMailMergeRecordStarted(object sender, SnapMailMergeRecordStartedEventArgs e)
{
if (e.RecordIndex == 3) {
for (int i = 0; i < e.RecordDocument.Fields.Count; i++) {
DevExpress.XtraRichEdit.API.Native.Field item = e.RecordDocument.Fields[i];
SnapImage snImage = e.RecordDocument.ParseField(item) as SnapImage;
if (snImage != null)
{
if (snImage.DataFieldName == "Picture")
{
snImage.BeginUpdate();
snImage.ScaleX = snImage.ScaleX * 2;
snImage.ScaleY = snImage.ScaleY * 2;
snImage.EndUpdate();
item.Update();
}
}
}
e.RecordDocument.EndUpdate();
// Another code snippet for the same result:
//e.RecordDocument.Fields[2].ShowCodes = true;
//e.RecordDocument.Replace(e.RecordDocument.Fields[2].CodeRange, @"SNIMAGE Picture \sy 20000 \sx 20000");
//e.RecordDocument.Fields[2].Update();
}
}