Generally, inserting page columns is a very easy task. Using the SectionFormat.Columns property, you can define the number of columns. TX Text Control will then automatically adjust the width of the columns based on the page size and number of columns.

But if the columns should have a different size and should not be averaged and spread out on the page, we need to set the width of each column. This can be done in the SectionFormat constructor:

public SectionFormat(int columns, int[] columnWidths, int[] columnDistances);

The second column width is calculated based on the first width, the distance between the columns, the page size and margins. This formula shows the calculation:

SecondColumnWidth = PageSize - PageMargins - FirstColumnWidth - ColumnDistance

The following code shows how to insert a new section with two columns where you just need to pass the first column width:

private void InsertColumns(int FirstColumnWidth, int ColumnDistance)
    TXTextControl.SectionFormat currentFormat =

    int iSecondColumnWidth = (int)(
        (currentFormat.PageSize.Width * 14.4) -
        (currentFormat.PageMargins.Left * 14.4) -
        (currentFormat.PageMargins.Right * 14.4) -
        FirstColumnWidth -

    TXTextControl.SectionFormat newSectionFormat =
        new TXTextControl.SectionFormat(
            new int[] { FirstColumnWidth, iSecondColumnWidth },
            new int[] { ColumnDistance });

    textControl1.Sections.GetItem().Format = newSectionFormat;

The following illustration gives an overview of the different required variables for our calculation: