Insert Data

[Top]  [Chapter]  [Previous]  [Next]

After the method MergeText was called the event OnFieldGetText will be triggered for each field.

 

Please use this event to prvide the field data.

 

This event receives the following parameters:

 

Editor, the number of the editor, usually 1

FieldName, the fieldname,

Contents, the interface IWPFieldContents to change the contents.

 

The interface IWPFieldContents has many options, but usually you will only need to modify the property StringValue:

 

VB:

 

Private Sub WPDLLInt1_OnFieldGetText(

 ByVal Editor As Long,

 ByVal FieldName As String,

 ByVal Contents As WPToolsInt.IWPFieldContents)

 

If FieldName="NAME" Then

    Contents.StringValue = 'Julian Ziersch'

End If

 

End Sub

 

C#

 

Private void wpdllInt1_OnFieldGetText(

 Object Sender,

 int Editor,

 String FieldName,

 WPDynamic.IWPFieldContents Contents)

 {

         If (FieldName.Equals("NAME"))  

                 Contents.StringValue = "Julian Ziersch";

 }

 

In the event OnFieldGetText you can access a database, calculate text or use fixed strings. The inserted text can be standard non formatted text, and it can be also RTF or HTML text.

 

Insert an image

 

You can insert a picture. If you use the OCX you can use any IPicture reference.

 

When using .NET convert an "Image" using the Image2Picture class:

 

Contents.LoadPicture(

 new WPDynamic.Image2Picture(

 pictureBox1.Image ),0,0 );

 

Change font attributes

 

The interface Contents.FieldAttr allows it to change the attributes of the inserted text, i.e. you can use it, for example, to make negative numbers red.

 

To start the mail merge use the method MergeText

 

 


[onfieldgettext.htm]    Copyright © 2007 by WPCubed GmbH