Back to Devexpress

RichEditControl.IsSelectionInTable() Method

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-6d54a174.md

latest5.0 KB
Original Source

RichEditControl.IsSelectionInTable() Method

Gets whether the entire selection is contained in one table.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public bool IsSelectionInTable()
vb
Public Function IsSelectionInTable As Boolean

Returns

TypeDescription
Boolean

true if a selection is within one table; otherwise, false.

|

Example

The following code activates the Table Tools Ribbon tab if the document selection is located in a document table.

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

View Example

csharp
static void richEditControl_SelectionChanged(object sender, EventArgs e) {
    RichEditControl richEdit = (sender as RichEditControl);
    BarButtonItem barButton = richEdit.Tag as BarButtonItem;
    barButton.Enabled = !richEdit.IsSelectionInTable();
}
vb
Private Shared Sub richEditControl_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
    Dim richEdit As RichEditControl = (TryCast(sender, RichEditControl))
    Dim barButton As BarButtonItem = TryCast(richEdit.Tag, BarButtonItem)
    barButton.Enabled = Not richEdit.IsSelectionInTable()
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the IsSelectionInTable() 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-rich-edit-implement-ms-office-word-format-painter/CS/DXApplication9/Form1.cs#L77

csharp
{
    tableToolsRibbonPageCategory1.Visible = richEditControl.IsSelectionInTable();
    floatingPictureToolsRibbonPageCategory1.Visible = richEditControl.IsFloatingObjectSelected;

winforms-richeditcontrol-common-api/CS/RichEditAPISample/CodeExamples/RichEditControlActions.cs#L311

csharp
BarButtonItem barButton = richEdit.Tag as BarButtonItem;
    barButton.Enabled = !richEdit.IsSelectionInTable();
}

winforms-rich-edit-implement-ms-office-word-format-painter/VB/DXApplication9/Form1.vb#L70

vb
Private Sub richEditControl_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
    tableToolsRibbonPageCategory1.Visible = richEditControl.IsSelectionInTable()
    floatingPictureToolsRibbonPageCategory1.Visible = richEditControl.IsFloatingObjectSelected

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

vb
Dim barButton As BarButtonItem = TryCast(richEdit.Tag, BarButtonItem)
    barButton.Enabled = Not richEdit.IsSelectionInTable()
End Sub

See Also

CaretPosition

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace