
An instance of the TableColumnCollection class contains all columns of a table in a Text Control document represented through objects of the type TableColumn. It can be obtained with the Table.Columns property. The TableColumnCollection class implements the IEnumerable and the ICollection interfaces.
[C#]
public sealed class TableColumnCollection: ICollection, IEnumerable
[Visual Basic]
Public NotInheritable Class TableColumnCollection
Implements ICollection
Implements IEnumerable
| Property | Description | |
| CanAdd | Gets a value indicating whether a new column can be inserted at the current input position. | |
| CanRemove | Gets a value indicating whether table columns can be removed. | |
| Count | Gets the number of columns contained in the table. |
| Method | Description | |
| Add | Adds a new table column at the current text input position. | |
| CopyTo | Copies the elements of the collection to an array, starting at a particular index. | |
| GetEnumerator | Returns an enumerator that can be used to iterate through the collection. | |
| GetItem | Gets a particular table column from the collection. | |
| Remove | Removes the table column at the current text input position or all selected table columns when a text selection exists. |
The following example shows how to use the table column collection.
[C#]
int myLastCol = myTable.Columns.Count;
TXTextControl.TableColumn myCol = myTable.Columns.GetItem(myLastCol);
TXTextControl.TableCell myCell = myTable.Cells.GetItem(1, myLastCol);
int myNewWidth = (int)(myCol.Width / 2);
textControl1.InputPosition = new TXTextControl.InputPosition(myCell.Start - 1);
if (myTable.Columns.CanAdd)
{
myCol.Width = myNewWidth;
myTable.Columns.Add(TXTextControl.TableAddPosition.After);
}
[Visual Basic]
Dim MyLastCol As Integer = MyTable.Columns.Count
Dim MyCol As TXTextControl.TableColumn = MyTable.Columns.GetItem(MyLastCol)
Dim MyCell As TXTextControl.TableCell = MyTable.Cells.GetItem(1, MyLastCol)
Dim MyNewWidth As Integer = CInt(MyCol.Width / 2)
TextControl1.InputPosition = New TXTextControl.InputPosition(MyCell.Start - 1)
If MyTable.Columns.CanAdd Then
MyCol.Width = MyNewWidth
MyTable.Columns.Add(TXTextControl.TableAddPosition.After)
End If