Table and Image selection

2 posts, 1 answers
  1. Johnny
    Johnny avatar
    2 posts
    Member since:
    Aug 2012

    Posted 04 Apr 2013 Link to this post

    Hi,

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

    Thanks,
    Johnny
  2. Answer
    Petya
    Admin
    Petya avatar
    975 posts

    Posted 09 Apr 2013 Link to this post

    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.

  3. DevCraft banner
Back to Top