OnCreateNewCell Event

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

Declaration C#

OnCreateNewCellEvent(Object Sender, int ColNr, int RowNr, IWPParInterface CellText, IWPAttrInterface CellAttr, int EventParam, ref bool AbortAtRowEnd)

 

Declaration OCX

OnCreateNewCell(ByVal ColNr As Long, ByVal RowNr As Long, ByVal CellText As WPTDynInt.IWPParInterface, ByVal CellAttr As WPTDynInt.IWPAttrInterface, ByVal EventParam As Long, AbortAtRowEnd As Boolean)

 

 

This event is triggered by method AddTable only if the variable EventParam was passed with a value <> 0.

The event makes it easy to assign text and attributes to each new cell.

 

VB Example:

Private Sub AddTable_Click()

   WPDLLInt1.TextCursor.AddTable "Catalog", 3, 1, True, 1000, True, True

End Sub

Private Sub WPDLLInt1_OnCreateNewCell(ByVal ColNr As Long, ByVal RowNr As Long, ByVal CellText As WPTDynInt.IWPParInterface, ByVal CellAttr As WPTDynInt.IWPAttrInterface, ByVal EventParam As Long, AbortAtRowEnd As Boolean)

   If RowNr > 0 Then

   CellText.AppendText "Cell " + Str(ColNr) + " in row " + Str(RowNr), 0

   Else

   CellText.ParShading = 30

   End If

End Sub

OnCreateNewCell

 

C# Example:

 

We use this event handler for OnCreateNewCell. The event is triggered for each created cell. The parameter EventParam is the value which was passed to AddTable. Please note that the last parameter must be ref bool AbortAtRowEnd - "out" instead of "ref" will not work.

 

 private void WPDLLInt1_OnCreateNewCell(object Sender, int ColNr, int RowNr,

         WPDynamic.IWPParInterface CellText,

         WPDynamic.IWPAttrInterface CellAttr,

         int EventParam, ref bool AbortAtRowEnd)

 {

                 CellText.SetText("some text",0);

 }

 

The process is started with this code:

 

          WPDLLInt1.TextCursor.AddTable(

                 "data", // optional name for table

                 3, //columns

                 10, //rows

                 true, // borders

                 1, // EventParam (!=0 to trigger callback)

                 false,// create header rows

                 false // create footer rows

          );

 

The value passed as parameter EventParam is provided to the event as well. If this parameter is 0, the event will not be triggered.

 

Note: To create a paragraph after the table created with AddTable call InputParagraph with Mode=2

 

 

Parameters

ColNr

This is the number of the current column. Its starts with 1

RowNr

This is the current row number. It is -1 if it is the header row, -2 for the footer row.

CellText

The IWPParInterface makes it possible to modify the text in this cell.

CellAttr

The IWPAttrInterface allows it to set the character atributes in this cell.

EventParam

This is the user variable which was passed to the AddTable function. Please remember, if this value was set to 0, the event will not be triggered.

AbortAtRowEnd

If this variable has been set to true inside the event the AddTable function will stop at the row end. If requested a footer row will still be added.

This variable is usefull if you do not know in advance how many rows should be added by AddTable. In this case pass a large number as row count and set AbortAtRowEnd to true when the last data row has been loaded.

Category

Callback Functions

Table Support


[idh_wpdllint_oncreatenewcell.htm]    Copyright © 2007 by WPCubed GmbH