on Load
this.radRichTextBox.Document.MailMergeDataSource.ItemsSource = new List<Employee>()
{
new Employee()
{
FirstName = "Guest1",
LastName = "Guest2",
},
new Employee()
{
FirstName = "Ali",
LastName = "Doc",
}
};
private void btnPrint_Click(object sender, RoutedEventArgs e)
{
//this.radRichTextBox.InsertField(new MergeField() { PropertyPath = "FirstName" });
MergeField field = new MergeField() { PropertyPath = "FirstName" };
field.DisplayMode = FieldDisplayMode.Result;
this.radRichTextBox.Document.ChangeFieldDisplayMode(field.FieldStart, FieldDisplayMode.Result);
}
7 Answers, 1 is accepted
Good to see your quick reply. I tried this out but facing some reference issues. Please can you send me latest complete project so that i can run and figure out the problem.
Additionally to what Shinu referenced, there is a demo on the topic. You can also find it here for Silverlight, but the code-base is the same.
I am also attaching a sample project which demonstrates how to set MailMergeDataSource. You an insert a merge field using the drop down button in the Mailings tab or the button on the bottom which will insert a field in result mode with the following code:
MergeField field =
new
MergeField() { PropertyPath =
"SenderFirstName"
,DisplayMode=FieldDisplayMode.Result };
this
.editor.InsertField(field);
I hope this helps! Let us know if you have other questions.
Regards,
Petya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Hi, as i seee you have large experience with merge fields, should you help me?
I am developing an application that list all merge fields and bookmarks in an user interface based on rich text documents (rtf). The user can change some merge fields and bookmaks properties. the bookmarks is done, but the merge fields i have problems to list and reference. the merge field will be selected in a list and highlighted in the editor, and the application provides the options to change his properties.
Could you please elaborate more on what are the difficulties you are facing for the case? What are the properties that the users can change? Is it an option to differentiate the merge fields by the properties from the source collection they point to?
Regards,
Tanya
Progress Telerik
Hi Tanya, my problem is not in data populate, i can explain better: My application is a rtf template conversor.
we get template from others and replace with out data, using bookmarks. i meet a lot of difficulties in this process, some of this is the
field kind the others work that. but i meet a solution, replace the text by bookmarks seraching the variable string name in the rtf content.
thank you!
Am I correct in thinking that you managed to achieve the desired goal? Nevertheless, I would like to mention that the merge fields are the built-in functionality that allows you to replace data in a template document with the records from a particular collection.
Regards,
Tanya
Progress Telerik