How to Find Table in RichTextbox

2 posts, 0 answers
  1. Sajid
    Sajid avatar
    8 posts
    Member since:
    Sep 2011

    Posted 08 Aug 2012 Link to this post


    I have a table in a richtextbox. I want to insert rows and columns at runtime to that table. Is it possible to add rows and columns to an existing table.

    1- Find that table
    2- Insert Rows/Columns to this table

    M. Rizwan
  2. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 09 Aug 2012 Link to this post

    Hi M. Rizwan,

    You can use the EnumerateChildrenOfType<Table>() method of RadDocument . In fact, all document elements have this method, which enables you to search for particular document elements which have a specific parent. For example, the following code will return the tables only in the first section of the document:

    var tablesInFirstSection = this.editor.Document.Sections.First.EnumerateChildrenOfType<Table>() ;

    As for inserting rows and columns in a table, you can use the following methods:

    These methods insert a table row relatively to the caret position and can only be executed when the caret is positioned in a table. Here is an example how you can move the document position to the beginning of the first cell in a table:
    Inline inlineInTable = table.Rows.First.Cells.First.Blocks.First.EnumerateChildrenOfType<Inline>().First();

    Kind regards,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top