Back to Devexpress

NoteCollection.Insert(DocumentPosition) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-notecollection-dot-insert-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentposition-x29.md

latest6.0 KB
Original Source

NoteCollection.Insert(DocumentPosition) Method

Inserts a new note into the specific document position.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
Note Insert(
    DocumentPosition position
)
vb
Function Insert(
    position As DocumentPosition
) As Note

Parameters

NameTypeDescription
positionDocumentPosition

A document position to insert a reference into.

|

Returns

TypeDescription
Note

A note (footnote or endnote).

|

Remarks

The code sample below shows how to insert a footnote and an endnote:

csharp
RichEditDocumentServer wordProcessor = new RichEditDocumentServer();
wordProcessor.LoadDocument("Document.docx");
Document document = wordProcessor.Document;

//Insert a footnote at the end of the 5th paragraph:
DocumentPosition footnotePosition = document.CreatePosition(document.Paragraphs[5].Range.End.ToInt() - 1);
document.Footnotes.Insert(footnotePosition);

//Insert an endnote at the end of the last paragraph:
DocumentPosition endnotePosition = document.CreatePosition(document.Paragraphs[document.Paragraphs.Count - 1].Range.End.ToInt() - 1);
document.Endnotes.Insert(endnotePosition);
vb
Dim wordProcessor As New RichEditDocumentServer()
wordProcessor.LoadDocument("Document.docx")
Dim document As Document = wordProcessor.Document

'Insert a footnote at the end of the 5th paragraph:
Dim footnotePosition As DocumentPosition = document.CreatePosition(document.Paragraphs(5).Range.End.ToInt() - 1)
document.Footnotes.Insert(footnotePosition)

' Insert an endnote at the end of the last paragraph:
Dim endnotePosition As DocumentPosition = document.CreatePosition(document.Paragraphs(document.Paragraphs.Count - 1).Range.End.ToInt() - 1)
document.Endnotes.Insert(endnotePosition)

The following code snippets (auto-collected from DevExpress Examples) contain references to the Insert(DocumentPosition) 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.

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Notes.cs#L16

csharp
DocumentPosition footnotePosition = document.CreatePosition(document.Paragraphs[5].Range.End.ToInt() - 1);
document.Footnotes.Insert(footnotePosition);

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/NotesActions.cs#L16

csharp
DocumentPosition footnotePosition = document.CreatePosition(document.Paragraphs[5].Range.End.ToInt() - 1);
document.Footnotes.Insert(footnotePosition);

word-document-api-examples/CS/CodeExamples/NotesActions.cs#L28

csharp
DocumentPosition footnotePosition = document.CreatePosition(document.Paragraphs[5].Range.End.ToInt() - 1);
document.Footnotes.Insert(footnotePosition);

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Notes.vb#L13

vb
Dim footnotePosition As DevExpress.XtraRichEdit.API.Native.DocumentPosition = document.CreatePosition(document.Paragraphs(CInt((5))).Range.[End].ToInt() - 1)
document.Footnotes.Insert(footnotePosition)
'Insert a footnote at the end of the 8th paragraph with a custom mark:

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/NotesActions.vb#L13

vb
Dim footnotePosition As DocumentPosition = document.CreatePosition(document.Paragraphs(5).Range.End.ToInt() - 1)
document.Footnotes.Insert(footnotePosition)

word-document-api-examples/VB/CodeExamples/NotesActions.vb#L30

vb
Dim footnotePosition As DevExpress.XtraRichEdit.API.Native.DocumentPosition = document.CreatePosition(document.Paragraphs(CInt((5))).Range.[End].ToInt() - 1)
document.Footnotes.Insert(footnotePosition)
' Insert a footnote at the end of the eighth paragraph with a custom mark.

See Also

NoteCollection Interface

NoteCollection Members

DevExpress.XtraRichEdit.API.Native Namespace