Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @DevExpressExampleBot
90 changes: 45 additions & 45 deletions CS/RichEditMasterDetailMailMerge.csproj
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Pictures\**" />
<EmbeddedResource Remove="Pictures\**" />
<None Remove="Pictures\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Data\template-intro.rtf" />
<None Remove="Data\template.docx" />
</ItemGroup>
<ItemGroup>
<None Update="Templates\Detail.rtf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Templates\Master.rtf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Templates\Template.rtf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="nwind.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DevExpress.Win.Design" Version="25.2.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="DevExpress.Win.RichEdit" Version="25.2.2" />
</ItemGroup>
<ItemGroup>
<Content Include="Data\template-intro.rtf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Data\template.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Pictures\**" />
<EmbeddedResource Remove="Pictures\**" />
<None Remove="Pictures\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Data\template-intro.rtf" />
<None Remove="Data\template.docx" />
</ItemGroup>
<ItemGroup>
<None Update="Templates\Detail.rtf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Templates\Master.rtf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Templates\Template.rtf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="nwind.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DevExpress.Win.Design" Version="25.2.1-alpha-25315" />
<PackageReference Include="DevExpress.Win.RichEdit" Version="25.2.1-alpha-25315" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Content Include="Data\template-intro.rtf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Data\template.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
25 changes: 18 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
<!-- default badges list -->
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/128609647/24.2.1%2B)
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/E3331)
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)
<!-- default badges end -->

# Rich Text Editor for WinForms - Create a Master-Detail Report

This example illustrates an older approach to creating master-detail documents.

> [!IMPORTANT]
> To learn about a newer and more convenient approach to master-detail mail merge, refer to the following article: [Create a Master-Detail Report with a Detail Report Band](https://docs.devexpress.com/XtraReports/4785/create-reports/create-a-master-detail-report-with-a-detail-report-band).
This example demonstrates the use of the Rich Text Editor's Mail Merge functionality to generate invoices from master-detail templates.

This project uses a two-level **Categories-Products** hierarchical data source, retrieved from the **nwind.xml** file.

![result](./media/96c27986-26f4-4775-b794-285e373adea7.png)

## Implementation Details

Rich Text Editor allows you to perform a mail merge with master-detail templates. The ``TableStart:Name`` and ``TableEnd:Name`` merge fields define master and detail regions. The region name should match the group or table name in your data source.

This example loads the template to the `RichEditControl` instance located in the **Main Template** tab.

![winforms richedit template tab](./media/richedit-template-tab.png)

Call the [RichEditControl.CreateMailMergeOptions()](https://docs.devexpress.com/OfficeFileAPI/DevExpress.XtraRichEdit.RichEditControl.CreateMailMergeOptions) method to create a new [MailMergeOptions](https://docs.devexpress.com/OfficeFileAPI/DevExpress.XtraRichEdit.API.Native.MailMergeOptions) object. This object contains mail merge options. Specify the object's [DataSource](https://docs.devexpress.com/OfficeFileAPI/DevExpress.XtraRichEdit.RichEditMailMergeOptions.DataSource) property to set the mail merge database.

Pass the `MailMergeOptions` object as the [RichEditControl.MailMerge](https://docs.devexpress.com/OfficeFileAPI/DevExpress.XtraRichEdit.RichEditControl.MailMerge.overloads) method parameter to apply specified options.

In this project, the [RichEditControl.MailMerge](https://docs.devexpress.com/OfficeFileAPI/DevExpress.XtraRichEdit.RichEditControl.MailMerge.overloads) exports the result to the `RichEditControl` instance located in the **Result** tab.

![winforms richedit template tab](./media/richedit-result-tab.png)

## Files to Review

* [Form1.cs](./CS/Form1.cs) (VB: [Form1.vb](./VB/Form1.vb))

## Documentation

* [How to: Create a Master-Detail Report](https://docs.devexpress.com/OfficeFileAPI/15329/word-processing-document-api/examples/mail-merge/master-detail-report)
* [Mail Merge in Rich Text Documents](https://docs.devexpress.com/WindowsForms/9330/controls-and-libraries/rich-text-editor/mail-merge)


<!-- feedback -->
Expand Down
Binary file added media/richedit-result-tab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/richedit-template-tab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.