AppendParagraph Method

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

Applies to

IWPDataBlock

Declaration

IWPParInterface AppendParagraph();

Description

This method appends a new paragraph to this text block and returns an IWPParInterface reference which can be used to manipulate this new paragraph. While it is easier to use the TextCursor methods to create a new header or footer, this method can be ideal to on the fly modify the text in header or footer since the cursor position does not have to be changed.

 

AppendParagraph

This header was created using the following C# code.

IWPAttrInterface currattr = wpdllInt1.CurrAttr;

// Create a custom header which will be printed only on page #2

IWPDataBlock block = wpdllInt1.Memo.BlockAdd(

     DataBlockKind.wpIsHeader,

     DataBlockRange.wpraOnFirstPage, "", 0);

block.Clear();

IWPParInterface par= block.AppendParagraph();

currattr.Clear();

currattr.SetFontface("Times New Roman");

currattr.SetFontSize(12);

par.AppendText("Documentation\tPage",-1); // use default attribute

par.InsertNewObject(1000,(int)TextObjTypes.wpobjTextObject,false,0,-1, "PAGE", "");

par.AppendText(" of ",-1);

par.InsertNewObject(1000,(int)TextObjTypes.wpobjTextObject,false,0,-1, "NUMPAGES", "");

// now also set tabstops

par.TabAdd(9000, 1, 3, 0);

If you need to create a second line you can use the API AppendNext:

par.AppendNext();

par.AppendText("Line 2",-1);

It is also possible to create a new table. (The IWPParInterface is a working interface, it always works on one paragraph. This paragraph can also be selected using the method SetPtr. AppendNext will automatically select the new paragraph.)

int tbl = par.AppendNext();

par.SetParType((int)ParagraphType.Table);

// We create a row object

int row = par.AppendChild();

// And now create 3 cells

par.SetPtr(row);

par.SetPtr(par.AppendChild());

par.AppendText("Cell A1",-1);

par.SetPtr(row);

par.SetPtr(par.AppendChild());

par.AppendText("Cell A2",-1);

par.SetPtr(row);

par.SetPtr(par.AppendChild());

par.AppendText("Cell A3",-1);

// Tip: to create a second row use

// par.SetPtr(tbl); and then create another row and cells

 

Please note that it is not possible to change the text in custom paint events.

Category

Table Support


[idh_iwpdatablock_appendparagraph.htm]    Copyright © 2007 by WPCubed GmbH