Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

MERGEFIELD

  • 2 minutes to read

MailMerge field

{ MERGEFIELD “field name“ [ switch ] [\* MERGEFORMAT] }

When the main document is merged with the selected data source, information from the specified data field is inserted in place of the merge field.

The MERGEFIELD field supports the following switches:

Switch Description
\* MERGEFORMAT Retains the formatting applied to the field.
\b “text Specifies the text to be inserted before the MERGEFIELD field if the field is not blank.
\f “text Specifies the text to be inserted after the MERGEFIELD field if the field is not blank.

Example:

{ MERGEFIELD FirstName \f” “ }{ MERGEFIELD MiddleName \f” “ }{ MERGEFIELD LastName }

If the MiddleName field data is missing (null), then there is only one space between FirstName and LastName:

David Bradley

Otherwise, MiddleName is separated by spaces as required:

David M Bradley

If the merge field is replaced with a DateTime value and no format switch is specified, the actual display format depends on the FieldOptions.UseCurrentCultureDateTimeFormat option. If this option is set to true, the RichEditDocumentServer uses settings specified by the DateTimeFormatInfo.ShortDatePattern property of the application’s current CultureInfo. If the FieldOptions.UseCurrentCultureDateTimeFormat is false (the default value), DateTime values use the “M/d/yyyy” format.

You can set the RichEditMailMergeOptions.ViewMergedData to true to display the MERGEFIELD fields’ code results.