This message contains graphics. If you do not see the graphics: Graphic Version.
 
How To Select Multiple Table Cells II, IC Imaging Control v1.3

How To Select Multiple Table Cells In 1 Or More Tables - Part 2

Two weeks ago we showed you how to select multiple cells in a table, independently. If you missed the newsletter, take a look at the section How To Select Multiple Table Cells In 1 Or More Tables - Part 1 in the newsletter archive.

This week we are going to expand the sample and add support for the insertion and deletion of a column. Afterwards, we will show you how to resize the table to fit the page.

Here is the code to insert a column:

Private Sub cmdInsertColumn_Click() Dim TableID As Integer With TXTextControl1 TableID = .TableAtInputPos If (TableID = 0) Then Exit Sub ' Try to insert a column If (Not .TableInsertColumn(txTableInsertAfter)) Then Exit Sub ' Now resize columns to fit the page ResizeTable TableID, (.PageWidth - .PageMarginL - .PageMarginR) End With End Sub

It simply calls TX Text Control's TableInsertColumn method with some error checking.

If the insertion of the column is successful, the ResizeTable sub is called. It takes a table id and the width to which the table should be resized as parameters.

All the columns are then resized to the same width. Here is the code:

Private Sub ResizeTable(TableID As Integer, Width As Integer) Dim CellWidth As Integer With TXTextControl1 CellWidth = Width / .TableColumns(TableID) .TableCellAttribute(TableID, 0, 0, txTableCellHorizontalExt) = CellWidth End With End Sub

As we want to resize all of the columns to the same width, we can use the TableCellAttributes property with the second and third parameter set to 0, which means all rows and all columns. So, the entire table is formatted at once.

You can download the code for this example here.

If you wish to discuss this example or need some help, please post your questions in the TX Text Control Forum.

IC Imaging Control v1.3 released

TX Text Control's sister product, IC Imaging Control was released last week in version 1.3. If you are interested, you can take a look at the updated feature list.

http://www.imagingcontrol.com/


Best regards

The Newsletter Team

Text Control GmbH respects your online time and privacy. We only send this newsletter to TX Text Control customers and people who have signed up to receive it. However, if you would prefer not to receive future issues of the newsletter, you may unsubscribe at any time. If you received this newsletter forwarded from a colleague or friend, you may wish to subscribe directly.

Sent to: N/A.

Imprint | Unsubscribe | Subscribe

© 2019 Text Control GmbH. All Rights Reserved.