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

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
public class TextColumnCollection

The TextColumnCollection type exposes the following members.

Public propertyCount
Gets the number of columns in the section of a document.
Public propertyCode exampleEvenlySpaced
True if text columns are of equal width and evenly spaced.
Public propertyCode exampleItem
Returns a text column at the specified index.
Public propertyCode exampleLineBetween
When true, adds a vertical line between columns.
Public propertyCode exampleSpacing
When columns are evenly spaced, gets or sets the amount of space between each column in points.
Public propertyWidth
When columns are evenly spaced, gets the width of the columns.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode exampleSetCount
Arranges text into the specified number of text columns.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)

Use SetCount(Int32) 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.

Creates multiple evenly spaced columns in a section using DocumentBuilder.

DocumentBuilder builder = new DocumentBuilder();

TextColumnCollection columns = builder.PageSetup.TextColumns;
// Make spacing between columns wider.
columns.Spacing = 100;
// This creates two columns of equal width.

builder.Writeln("Text in column 1.");
builder.Writeln("Text in column 2.");

builder.Document.Save(ArtifactsDir + "PageSetup.ColumnsSameWidth.doc");
See Also