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


   CellText.ParShading = 30

   End If

End Sub



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:



                 "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





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


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


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


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


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.


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.


Callback Functions

Table Support

[idh_wpdllint_oncreatenewcell.htm]    Copyright © 2007 by WPCubed GmbH