Extension methods add methods to existing members without inheriting, recompiling, or otherwise modifying the original type. We use this concept to create a method that extends the Table object in TX Text Control. The method ConvertToTabs converts a table to tab positions.
Table Extension Method
The following code shows the extension method:
This method can be called on any table with fewer than 15 columns and no nested tables. The following code calls the extension method on the table at the current input position:
How does it Work?
The method basically loops through all table rows and columns to store the position of each table cell and the text it contains in the internal TX Text Control format. In a second loop through this created list, tab positions are applied and the text is loaded separated by a tab character.