| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | C# |
| Version: | 1.0 |
| Released: | September 18, 2007 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control .NET with C# |
| Download code: | tx_sample_addtablerowtab.zip |
Word processing applications handle the situation in which the cursor is in the final cell of a table and then the tab key is pressed by adding a new row to the table.
This functionality does not ship as standard in TX Text Control. This brief sample, however, illustrates how to implement such functionality in just a few lines of code.
If the current input position is in the last cell, the KeyPress event can be used to recognize, whether the user presses the tab key. To check, if the cursor is in the last cell, it is easy to compare the current column with the TableColumnCollection.Count property and the current row with the TableRowCollection.Count property. This is illustrated in the following code:
TXTextControl.Table curTable; if (textControl1.Tables.GetItem() == null) return; else curTable = textControl1.Tables.GetItem(); int columnCount = curTable.Columns.Count; int rowCount = curTable.Rows.Count; if (e.KeyChar == 9 && curTable.Columns.GetItem().Column == _columnCount && curTable.Rows.GetItem().Row == rowCount) { e.Handled = true; textControl1.Tables.GetItem().Rows.Add(TXTextControl.TableAddPosition.After, 1); }
The minimum requirements for this sample application are TX Text Control .NET trial version and C# 2005.