Back to Devexpress

RichEditControl.DeselectAll() Method

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-aa02f842.md

latest3.7 KB
Original Source

RichEditControl.DeselectAll() Method

Specifies that no content is selected in the control.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public void DeselectAll()
vb
Public Sub DeselectAll

Example

The following code resets document selection and sets the caret to the end of the former selection.

The RichEditControl instance is passed to the BarItem.ItemClick event handler using the BarItem.Tag property.

View Example

csharp
static void buttonCustomAction_ItemClick_Deselect(object sender, ItemClickEventArgs e) {
    RichEditControl richEdit = e.Item.Tag as RichEditControl;
    DocumentPosition endOfSelection = richEdit.Document.Selection.End;
    richEdit.DeselectAll();
    richEdit.Document.CaretPosition = endOfSelection;
}
vb
Private Shared Sub buttonCustomAction_ItemClick_Deselect(ByVal sender As Object, ByVal e As ItemClickEventArgs)
    Dim richEdit As RichEditControl = TryCast(e.Item.Tag, RichEditControl)
    Dim endOfSelection As DocumentPosition = richEdit.Document.Selection.End
    richEdit.DeselectAll()
    richEdit.Document.CaretPosition = endOfSelection
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DeselectAll() 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-richeditcontrol-common-api/CS/RichEditAPISample/CodeExamples/RichEditControlActions.cs#L439

csharp
DocumentPosition endOfSelection = richEdit.Document.Selection.End;
richEdit.DeselectAll();
richEdit.Document.CaretPosition = endOfSelection;

winforms-richeditcontrol-common-api/VB/RichEditAPISample/CodeExamples/RichEditControlActions.vb#L447

vb
Dim endOfSelection As DocumentPosition = richEdit.Document.Selection.End
richEdit.DeselectAll()
richEdit.Document.CaretPosition = endOfSelection

See Also

SelectAll()

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace