Function TWPCustomRtfEdit.TableAdd(colcount:Integer; RowCount:Integer; Options:TWPTableAddOptions; StyleForNewCells:TWPTextStyle; CallBackForText:TWPTableAddCellEvent; StyleForHeader:TWPTextStyle; StyleForFooter:TWPTextStyle; WidthSourceRow:TParagraph; RowGroupLevel:Integer) : TParagraph
Unit: WPCTRMemo
Class: WPCTRMemo.TWPCustomRtfEdit
Parameters
-
colcount:Integer RowCount:Integer Options:TWPTableAddOptions StyleForNewCells:TWPTextStyle CallBackForText:TWPTableAddCellEvent StyleForHeader:TWPTextStyle StyleForFooter:TWPTextStyle WidthSourceRow:TParagraph RowGroupLevel:Integer
Returns
The type of the result value is TParagraph.
Description
Create a new table. It is possible to provide a callback function which can be used to format and fill each created cell.StyleForNewCells is used for all cells, unless StyleForHeader and StyleForFooter were specified which are used for header and footer cells.
Example:
procedure TForm1.AddCell(RowNr, ColNr: Integer; par: TParagraph);
begin
par.SetText(Format('%d %d',[RowNr, ColNr]));
if RowNr=1 then
par.ASetColor(WPAT_FGColor, clGreen) else
begin
if (RowNr-1) and 1=1 then
par.ASetColor(WPAT_FGColor,clRed) // ungerade
else par.ASetColor(WPAT_FGColor,clBlue); // ungerade
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
WPRichText1.TableAdd(3,5,[wptblActivateBorders],nil, AddCell);
WPRichText1.ReformatAll();
end;
wpstLevelEnd can be set in par.State in CallBackForText to create a new row as parent of the rest
of cells in the current run with 1..colcount cells.
procedure TForm1.AddCell(RowNr, ColNr: Integer; par: TParagraph);
begin
par.SetText(Format('%d %d',[RowNr, ColNr]));
if (ColNr=2) then par.State := par.State + [wpstLevelEnd];
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
WPRichText1.TableAdd(5,3,[wptblActivateBorders],nil, AddCell);
WPRichText1.ReformatAll();
end;
Overloaded Methods
Function TWPCustomRtfEdit.TableAdd(ColCount:Integer; RowCount:Integer; CallBackProcedure:TWPTableAddCellCallback; Options:TWPTableAddOptions) : TParagraph |