TX Text Control Blog

Adjusting table columns using inches

Blogged by Gunnar Giffey on April 5, 2005 and tagged with samples, .net.

Recently, I have received several questions concerning metrics for tables and how to adjust rows and columns to a given value.

As height and width are measured in twips, it is necessary to convert the value from inches or centimeters in to twips. The conversion is as follows:

1 inch = 1440 twips1 cm = 567 twips

Knowing this unit of conversion, it is easy to adjust the width to 0.5 inches, for example. The following Visual Basic source code illustrates how to achieve this:

Private Sub columnWidthAdjust() Dim i As Integer For i = TXTextControl1.TableColumns( TXTextControl1.TableAtInputPos) To 1 Step -1 TXTextControl1.TableCellAttribute(TXTextControl1. TableAtInputPos, 0, i, txTableCellHorizontalExt) = 720 Next i End Sub

Please note that each column is adjusted separately. Therefore, it is possible to add an array that contains different widths that can in turn be assigned to columns.