This is a migrated thread and some comments may be shown as answers.

Insert Mergfield problems

4 Answers 202 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Gudrun
Top achievements
Rank 1
Gudrun asked on 05 Aug 2011, 12:25 PM
Hi,

In "code-behind" I use the InsertField method to insert a MergeField into the document.. The problem is when i open the document in msWord the FontType is wrong and when i open the document after save in RichEdit the fields isn't visible.. Is there a way to fix this?

Code sample:
view.editor.InsertField(new MergeField() { PropertyPath = "Number" });

4 Answers, 1 is accepted

Sort by
0
Gudrun
Top achievements
Rank 1
answered on 10 Aug 2011, 01:38 PM
I found a solution for this:
if (e.Command is OpenDocumentCommand)
{
    View.editor.Commands.ChangeAllFieldsDisplayModeCommand.Execute("DisplayName");
}

The problem with the Font is probably a bug, the font formating is fine if I save the document as a rtf file instead of docx..

Have also countered some other bugs when I use mailmerge and the docx format

Gudrun
0
Iva Toteva
Telerik team
answered on 11 Aug 2011, 09:32 AM
Hi Gudrun,

Thank you for getting to us about the export of merge fields.
The format providers export the result of the merge fields and when a merge source has not been set, the fields are not visible in the exported document. We have planned to add customization settings to the provider, so that merge fields can be exported using their display name/display code.
The workaround you have found should work correctly.
If you have encountered other bugs, we would appreciate it if you could share them with us.

Regards,
Iva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Roberto Pantalena
Top achievements
Rank 1
answered on 03 Jan 2012, 05:55 PM
HI, i would like to know what type of parameter i have to put on calling the "InsertEmptyMergeFieldCommand".. it's possible to know and insert a Merge Field?
0
Boby
Telerik team
answered on 06 Jan 2012, 10:36 AM
Hi Roberto,
InsertMergeFieldEmptyCommand is infrastucture command used for binding the RadRichTextBoxRibbonUI. If you want a command that inserts a merge field, you can use InsertFieldCommand, which accepts as parameter a Field and inserts it at the current caret position:
 
<telerik:RadRibbonToggleButton Size="Medium" Text="Bind" Command="{Binding ElementName=radRichTextBox, Path=Commands.InsertFieldCommand}">
    <telerik:RadRibbonToggleButton.CommandParameter>
        <telerik:MergeField PropertyPath="FirstName" />
    </telerik:RadRibbonToggleButton.CommandParameter>
</telerik:RadRibbonToggleButton>
You can read more about mail merge in this help article.

Don't hesitate to contact us if you have other questions.

Kind regards,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
Gudrun
Top achievements
Rank 1
Answers by
Gudrun
Top achievements
Rank 1
Iva Toteva
Telerik team
Roberto Pantalena
Top achievements
Rank 1
Boby
Telerik team
Share this question
or