- Offizieller Beitrag
Q: Below is a test of the suggested code for creating a table (from the V5
docs). It shows the cell contents, but no borders. It seems to me it
should show borders, so what am I doing wrong?
Code
procedure TForm1.Button1Click(Sender: TObject);
var
aCell: TParagraph;
begin
with WPRichText1.Memo.DisplayedText.CreateTable(nil) do begin
ASet(WPAT_BorderFlags, WPBRD_DRAW_All4);
with CreateRow(nil, TRUE) do begin
InputCell.SetText('Cell 1');
InputCell.SetText('Cell 2');
EndRow(ThisRowStyle);
end;
with CreateRow(nil, TRUE) do begin
InputCell.SetText('Cell 3');
InputCell.SetText('Cell 4');
EndRow(ThisRowStyle);
end;
WPRichText1.EndTable; // this line and the next one (which are
not in the docs) are required if the table is to show at all
WPRichText1.Refresh;
end;
end;
Alles anzeigen
A: In this example the table (= parent of all rows) gets a border but this is currently not displayed since RTF does not use this paradigm.
The ASet(WPAT_BorderFlags, WPBRD_DRAW_All4); should be
after the CreateRow(nil, TRUE).
Explanation: CreateRow creates an object which is used to handle the creation of a table row. This object is freed by EndRow.
The object inherits from TWPTextStyle and is used as default style for all cells when they are created. (This means you can add and remove properties while you are creating styles)