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
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
Category |