officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentrange-dot-endupdatedocument-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-subdocument-x29.md
Finalizes modifications of the document obtained via the document’s range (e.g. via selection).
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
void EndUpdateDocument(
SubDocument document
)
Sub EndUpdateDocument(
document As SubDocument
)
| Name | Type | Description |
|---|---|---|
| document | SubDocument |
A SubDocument instance obtained via the previously called DocumentRange.BeginUpdateDocument method.
|
Use the DocumentRange.BeginUpdateDocument - DocumentRange.EndUpdateDocument pair to modify the document obtained via selection (i.e. by using the Document.Selection property). In that case, it is very important to distinguish different parts of the document, such as header, footer or body. The EndUpdateDocument method implements this requirement.
The following code replaces the selected text with asterisks.
The RichEditControl instance is passed to the BarItem.ItemClick event handler using the BarItem.Tag property.
Private Shared Sub buttonCustomAction_ItemClick_Replace(ByVal sender As Object, ByVal e As ItemClickEventArgs)
Dim richEdit As RichEditControl = TryCast(e.Item.Tag, RichEditControl)
Dim range As DocumentRange = richEdit.Document.Selection
Dim selLength As Integer = range.Length
Dim s As New String("*"c, selLength)
Dim doc As SubDocument = range.BeginUpdateDocument()
doc.InsertSingleLineText(range.Start, s)
Dim rangeToRemove As DocumentRange = doc.CreateRange(range.Start, selLength)
doc.Delete(rangeToRemove)
range.EndUpdateDocument(doc)
End Sub
static void buttonCustomAction_ItemClick_Replace(object sender, ItemClickEventArgs e) {
RichEditControl richEdit = e.Item.Tag as RichEditControl;
DocumentRange range = richEdit.Document.Selection;
int selLength = range.Length;
string s = new String('*', selLength);
SubDocument doc = range.BeginUpdateDocument();
doc.InsertSingleLineText(range.Start, s);
DocumentRange rangeToRemove = doc.CreateRange(range.Start, selLength);
doc.Delete(rangeToRemove);
range.EndUpdateDocument(doc);
}
The following code snippets (auto-collected from DevExpress Examples) contain references to the EndUpdateDocument(SubDocument) 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-save-text-from-a-range-in-different-formats/CS/GetTextMethodsExample/Form1.cs#L34
mhtText = doc.GetMhtText(selection);
selection.EndUpdateDocument(doc);
}
winforms-rich-edit-implement-ms-office-word-format-painter/CS/DXApplication9/Form1.cs#L87
sourceSelectedRange = subDocument.CreateRange(selection.Start, richEditControl.Document.Selection.Length);
selection.EndUpdateDocument(subDocument);
}
winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Export.cs#L66
string plainText = docRange.GetText(docRange.Range);
document.Selection.EndUpdateDocument(docRange);
winforms-richeditcontrol-common-api/CS/RichEditAPISample/CodeExamples/RichEditControlActions.cs#L483
doc.Delete(rangeToRemove);
range.EndUpdateDocument(doc);
}
wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/TableActions.cs#L223
String.Format("{0}*{1} = {2}", i + 2, j + 2, (i + 2) * (j + 2)));
cell.Range.EndUpdateDocument(doc);
}
winforms-richedit-save-text-from-a-range-in-different-formats/VB/GetTextMethodsExample/Form1.vb#L30
mhtText = doc.GetMhtText(selection)
selection.EndUpdateDocument(doc)
Else
winforms-rich-edit-implement-ms-office-word-format-painter/VB/DXApplication9/Form1.vb#L79
sourceSelectedRange = subDocument.CreateRange(selection.Start, richEditControl.Document.Selection.Length)
selection.EndUpdateDocument(subDocument)
End Sub
winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Export.vb#L59
Dim plainText As String = docRange.GetText(docRange.Range)
document.Selection.EndUpdateDocument(docRange)
DevExpress.XtraEditors.XtraMessageBox.SmartTextWrap = True
winforms-richeditcontrol-common-api/VB/RichEditAPISample/CodeExamples/RichEditControlActions.vb#L501
doc.Delete(rangeToRemove)
range.EndUpdateDocument(doc)
End Sub
wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/TableActions.vb#L197
doc.InsertText(cell.Range.Start, String.Format("{0}*{1} = {2}", i + 2, j + 2, (i + 2) * (j + 2)))
cell.Range.EndUpdateDocument(doc)
End Sub
See Also