With the introduction of version 17.0, TX Text Control users can now select table columns with one click on the down arrow in the first table row. Or you can simply click and drag to select some cells. Additionally, you no longer have to select cells row-wise. Multiple cells can be selected in the middle of a table.

The shipped dialog box can be used to modify the cell formatting of selected table cells. The following code shows how to format selected cells using the API instead of the dialog box.

private void SetCellFormat(TableCellFormat CellFormat)
{
    Table table = textControl1.Tables.GetItem();

    if (table == null)
        return;

    Selection curSelection = new Selection(
        textControl1.Selection.Start,
        textControl1.Selection.Length);

    textControl1.Selection.Length = 0;

    // start row and col
    int iTableStartRow = table.Cells.GetItem().Row;
    int iTableStartCol = table.Cells.GetItem().Column;

    textControl1.Selection.Start =
        curSelection.Start + curSelection.Length - 1;

    // end row and col
    int iTableEndRow = table.Cells.GetItem().Row;
    int iTableEndCol = table.Cells.GetItem().Column;

    // loop through all cells and check whether they are in the
    // range of selected cells
    foreach (TableCell cell in textControl1.Tables.GetItem().Cells)
    {
        if (cell.Row >= iTableStartRow &&
            cell.Row <= iTableEndRow &&
            cell.Column <= iTableEndCol &&
            cell.Column >= iTableStartCol)

            cell.CellFormat = CellFormat;
    }
}

The code pretty straightforward: Using the TableCellCollection.GetItem method, the table row and column at the beginning and the end of the selection is stored in a variable. Then, all cells are iterated using the TableCellCollection. Each cell's row and column property is checked whether it is in the range of the selected cells.