InputTable Method

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

Creates and fills a table not using a callback

Applies to

IWPTextCursor

Declaration

void InputTable(int Width, string Name);

Description

Creates a table object. Create each row with InputRowStart followed by some InputCell and finished by InputRowEnd. Use InputParagraph to create text after the table. You can use MoveToTable to later locate the table.

 

Note: Please make sure to create an empty paragraph at the end of a text - otherwise some RTF readers have problems to load it. To do so use InputParagraph when the table is complete.

 

This C# example creates a table with 10 rows and 3 columns:

 

IWPMemo Memo;

Memo = WPDLLInt1.Memo;

IWPTextCursor TextCursor = Memo.TextCursor;

IWPAttrInterface CurrParAttr = Memo.CurrParAttr;

TextCursor.InputTable(0, "data");

For (int r = 0; r < 10; r++)

{

       TextCursor.InputRowStart(1);

       For(int c = 0; c < 3; c++)

       {

        TextCursor.InputCell("some text", "");

        // This cell should use bold Text

        If(c==0)CurrParAttr.IncludeStyles(1);

       }

       TextCursor.InputRowEnd();

}

TextCursor.InputParagraph(0,"");

Memo.Reformat();

 

This code creates a table by appending one row and one cell after each other. After the creation of each cell this cell can be modified using the CurrParAttr and CurrPar interfaces.

 

The table is created named as "data". So you can use TextCursor.MoveToTable("data") to move the cursor to the first cell in this table anytime later.

 

You can use CurrPar and CurrParAttr to modify the tables, rows and cells right after the have been created.

 

This C# example creates a table with 5 rows and 2 cells, width = 10 and 90%:

 

IWPMemo memo = wpdllInt1.Memo;

IWPAttrInterface atr = wpdllInt1.AttrHelper;

IWPParInterface par = memo.CurrPar;

IWPAttrInterface parattr = memo.CurrParAttr;

IWPTextCursor cursor = memo.TextCursor;

// Start a table

 cursor.InputTable(0,"");

// use 50 % of the page width

 par.ParASet((int)WPAT.BoxWidth_PC, 50*100);

// Now create 5 rows

 For (int r = 1; r <= 5; r++)

 {

    cursor.InputRowStart(0);

    // With 2 cells Each, 10 And 90 % width

     cursor.InputCell(r.ToString(),"");

     par.ParASet((int)WPAT.COLWIDTH_PC, 10*100);

     par.ParColor = wpdllInt1.ColorToRGB(Color.Gray);

     parattr.IncludeStyles(1); // bold Text

    // The second cell uses different Text attributes

     cursor.InputCell("","");

     par.ParASet((int)WPAT.COLWIDTH_PC, 90*100);

    // Append normal Text

     atr.Clear();

     par.AppendText("Normal ", atr.CharAttrIndex);

     atr.IncludeStyles(1); // bold Text

     par.AppendText("and bold", atr.CharAttrIndex);

    // This row is finished

     cursor.InputRowEnd();

 }

// Format And display

 memo.ReformatAll(False, True);

Category

Table Support


[idh_iwptextcursor_inputtable.htm]    Copyright © 2007 by WPCubed GmbH