Useful code samples for table handling

<< Click to Display Table of Contents >>

Navigation:  Programming > Change text attributes in code > Numbering > Tables >

Useful code samples for table handling

This example creates a new row when ENTER is pressed at the last position of a row.

 

procedure TWPEditor.WPRichText1KeyDown(Sender: TObject; var Key: Word;

 Shift: TShiftState);

begin

if (Key=VK_RETURN) and

    (WPRichText1.ActivePosInPar>=WPRichText1.ActiveParagraph.CharCount)and

    (WPRichText1.TableCell<>nil) and (WPRichText1.TableCell.NextPar=nil) then

begin

    WPRichText1.TableRow.Duplicate(false, true, false);

    WPRichText1.ActiveParagraph := WPRichText1.TableRow.NextPar.ColFirst;

    // Duplicate is low level - we need to call Reformat manually

    WPRichText1.ReformatAll(false, true);

    Key := 0;

end;

end;