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
Regards
M. Rizwan
1 Answer, 1 is accepted
0
Iva Toteva
Telerik team
answered on 09 Aug 2012, 09:29 AM
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:
this.editor.InsertTableRowAbove();
this.editor.InsertTableRowBelow();
this.editor.InsertTableColumnToTheLeft();
this.editor.InsertTableColumnToTheRight();
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: