This is a migrated thread and some comments may be shown as answers.

Table and Image selection

1 Answer 56 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Johnny
Top achievements
Rank 1
Johnny asked on 05 Apr 2013, 03:13 AM
Hi,

How do I know if current selection is a table or an image in a document?

Thanks,
Johnny

1 Answer, 1 is accepted

Sort by
0
Accepted
Petya
Telerik team
answered on 09 Apr 2013, 03:22 PM
Hi Johny,

One possible approach would be to create a new document from the selection and enumerate it's table/image elements like this:
if (!this.radRichTextBox.Document.Selection.IsEmpty)
{
    RadDocument document = new RadDocument();
    document.InsertFragment(new DocumentFragment(this.radRichTextBox.Document.Selection));
 
    if (document.EnumerateChildrenOfType<Table>().Count() > 0)
    {
        MessageBox.Show("Contains table");
    }
    if (document.EnumerateChildrenOfType<ImageInline>().Count() > 0)
    {
        MessageBox.Show("Contains image");
    }
}

Let me know if you have other questions.

Regards,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Johnny
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or