TextColumnCollection

TextColumnCollection class

A collection of TextColumn objects that represent all the columns of text in a section of a document.

public class TextColumnCollection

Properties

Name Description
Count { get; } Gets the number of columns in the section of a document.
EvenlySpaced { get; set; } True if text columns are of equal width and evenly spaced.
Item { get; } Returns a text column at the specified index.
LineBetween { get; set; } When true, adds a vertical line between columns.
Spacing { get; set; } When columns are evenly spaced, gets or sets the amount of space between each column in points.
Width { get; } When columns are evenly spaced, gets the width of the columns.

Methods

Name Description
SetCount(int) Arranges text into the specified number of text columns.

Remarks

Use SetCount to set the number of text columns.

To make all columns equal width and spaced evenly, set EvenlySpaced to true and specify the amount of space between the columns in Spacing. MS Word will automatically calculate column widths.

If you have EvenlySpaced set to false, you need to specify width and spacing for each column individually. Use the indexer to access individual TextColumn objects.

When using custom column widths, make sure the sum of all column widths and spacings between them equals page width minus left and right page margins.

Examples

Shows how to create multiple evenly spaced columns in a section.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

TextColumnCollection columns = builder.PageSetup.TextColumns;
columns.Spacing = 100;
columns.SetCount(2);

builder.Writeln("Column 1.");
builder.InsertBreak(BreakType.ColumnBreak);
builder.Writeln("Column 2.");

doc.Save(ArtifactsDir + "PageSetup.ColumnsSameWidth.docx");

See Also