Back to Devexpress

ParagraphCollection.Append() Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-paragraphcollection.md

latest6.9 KB
Original Source

ParagraphCollection.Append() Method

Appends a new Paragraph to the document.

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
Paragraph Append()
vb
Function Append As Paragraph

Returns

TypeDescription
Paragraph

A Paragraph object that is the newly added paragraph.

|

Remarks

The code sample below appends a paragraph and inserts a paragraph at the start of the second section:

csharp
using DevExpress.XtraRichEdit.API.Native;

using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
    wordProcessor.LoadDocument("FirstLook.docx");
    Document document = wordProcessor.Document;
    document.BeginUpdate();

    //Append paragraph:
    Paragraph appendedParagraph = document.Paragraphs.Append();
    document.InsertText(appendedParagraph.Range.Start, "Appended paragraph");

    //Insert paragraph at the start of the second section:
    Paragraph paragraph = document.Paragraphs.Insert(document.Sections[1].Range.Start);
    document.InsertText(document.Paragraphs[paragraph.Index - 1].Range.Start,
         "Inserted paragraph");
    document.EndUpdate();
}
vb
Imports DevExpress.XtraRichEdit.API.Native

Using wordProcessor As New RichEditDocumentServer()
    wordProcessor.LoadDocument("FirstLook.docx")
    Dim document As Document = wordProcessor.Document
    document.BeginUpdate()

    'Append paragraph:
    Dim appendedParagraph As Paragraph = document.Paragraphs.Append()
    document.InsertText(appendedParagraph.Range.Start, "Appended paragraph")

    'Insert paragraph at the start of the second section:
    document.InsertText(document.Paragraphs[paragraph.Index - 1].Range.Start
         "Inserted paragraph");
    document.InsertText(paragraph.Range.Start, "Inserted paragraph")
    document.EndUpdate()
End Using

The following code snippets (auto-collected from DevExpress Examples) contain references to the Append() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

word-document-api-examples/CS/CodeExamples/BookmarksAndHyperlinks.cs#L29

csharp
// Create a hyperlink that navigates to the created bookmark.
wordProcessor.Document.Paragraphs.Append();
DocumentRange hyperlinkRange = wordProcessor.Document.AppendText("get to the top");

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Range.cs#L38

csharp
string s2 = String.Format("Range r2 starts at {0}, ends at {1}", r2.Start, r2.End);
document.Paragraphs.Append();
document.AppendText(s1);

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/RangeActions.cs#L38

csharp
string s2 = String.Format("Range r2 starts at {0}, ends at {1}", r2.Start, r2.End);
document.Paragraphs.Append();
document.AppendText(s1);

word-document-api-insert-dynamic-content/CS/Program.cs#L72

csharp
{
    Paragraph paragraph = document.Paragraphs.Append();
    paragraph.LineSpacing = 1f;

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Range.vb#L35

vb
Dim s2 As String = System.[String].Format("Range r2 starts at {0}, ends at {1}", r2.Start, r2.[End])
document.Paragraphs.Append()
document.AppendText(s1)

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/RangeActions.vb#L33

vb
Dim s2 As String = String.Format("Range r2 starts at {0}, ends at {1}", r2.Start, r2.End)
document.Paragraphs.Append()
document.AppendText(s1)

word-document-api-examples/VB/CodeExamples/BookmarksAndHyperlinks.vb#L29

vb
' Create a hyperlink that navigates to the created bookmark.
document.Paragraphs.Append()
Dim hyperlinkRange As DocumentRange = wordProcessor.Document.AppendText("get to the top")

word-document-api-invoke-print-preview-dialog/VB/Form1.vb#L31

vb
richServer.Document.AppendText("This content is created programmatically" & Microsoft.VisualBasic.Constants.vbLf)
richServer.Document.Paragraphs.Append()
'Create a table

word-document-api-insert-dynamic-content/VB/Module1.vb#L60

vb
Private Sub AddSyndicationItem(ByVal document As Document, ByVal item As SyndicationItem)
    Dim paragraph As Paragraph = document.Paragraphs.Append()
    paragraph.LineSpacing = 1.0F

See Also

ParagraphCollection Interface

ParagraphCollection Members

DevExpress.XtraRichEdit.API.Native Namespace