officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-notecollection-dot-insert-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentposition-x29.md
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
Note Insert(
DocumentPosition position
)
Function Insert(
position As DocumentPosition
) As Note
| Name | Type | Description |
|---|---|---|
| position | DocumentPosition |
A document position to insert a reference into.
|
| Type | Description |
|---|---|
| Note |
A note (footnote or endnote).
|
The code sample below shows how to insert a footnote and an endnote:
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);
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
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
DocumentPosition footnotePosition = document.CreatePosition(document.Paragraphs[5].Range.End.ToInt() - 1);
document.Footnotes.Insert(footnotePosition);
word-document-api-examples/CS/CodeExamples/NotesActions.cs#L28
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
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
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
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