property MergeAttr: TWPStoredCharAttrInterface

<< Click to Display Table of Contents >>

Navigation:  Programming > Mail Merge (replace fields with data) and data forms > Update Field (Insert Text from Database) > Event OnMailMergeGetText > TWPMMInsertTextContents >

property MergeAttr: TWPStoredCharAttrInterface

This interface allows it to modify the attributes of the text which is about to be inserted.

 

Also see: "Preserve Attributes of text inside a field"

 

You can use the methods of the AttributeInterfaces.

 

Example:

Contents.MergeAttr.SetColor(clRed);

 

The object 'MergeAttr' is initialized with the character properties of the start object of the mailmerge field. If you want to use the first character of the merged text (this is the visible field name or the field data) You can use this code in the the OnMailMergeGetText event:

 

 Contents.MergeAttr.CharAttr :=

     Contents.MergePar.CharAttr[

        Contents.MergeParPos+1];

 

This code assigns the character attribute of the character which follows the the mergefield start code (= the merge text).

 

You can, for example, change the font name:

Contents.MergeAttr.SetFontName(...);

 

This can be very useful if you need to display checkboxes in the fields. In this case simply assigne the desired wingdings characters code to StringValue.

 

Contents.MergeAttr.SetFontName

if data=true then

       Contents.StringValue := #254 // þ

else Contents.StringValue := #168; // ¨