Click or drag to resize

TextColumnCollection Class

Represents a collection of text columns in a section.
Inheritance Hierarchy
SystemObject
  System.Collections.ObjectModelReadOnlyCollectionTextColumn
    SautinSoft.DocumentTextColumnCollection

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.7.18
Syntax
public sealed class TextColumnCollection : ReadOnlyCollection<TextColumn>

The TextColumnCollection type exposes the following members.

Constructors
 NameDescription
Public methodCode exampleTextColumnCollection Initializes a new instance of the TextColumnCollection class.
Top
Properties
 NameDescription
Public propertyCode exampleEvenlySpaced Gets or sets a value indicating whether all text columns have equal width and are evenly spaced.
Public propertyLineBetween Gets or sets a value indicating whether to show or not the line between two TextColumn.
Public propertySpaceBetween Gets or sets the amount of space between each column (in points). Set this property only if EvenlySpaced is .
Top
Example

See Developer Guide: How to work with text columns in a document

How to work with text columns in a document using C#
using SautinSoft.Document;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            // Get your free 100-day key here:   
            // https://sautinsoft.com/start-for-free/

            TextColumns();
        }

        /// <summary>
        /// Working with text columns. 
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/help/net/developer-guide/text-columns.php
        /// </remarks>
        public static void TextColumns()
        {
            string documentPath = @"TextColumns.docx";

            // Let's create a document with 4 columns.
            DocumentCore dc = new DocumentCore();

            // Add new section
            Section s = new Section(dc);
            dc.Sections.Add(s);

            s.PageSetup.PageMargins = new PageMargins()
            {
                Top = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
                Right = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
                Bottom = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
                Left = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point)
            };

            s.PageSetup.TextColumns = new TextColumnCollection(4);
            s.PageSetup.TextColumns.EvenlySpaced = false;
            s.PageSetup.TextColumns[0].Width = LengthUnitConverter.Convert(60, LengthUnit.Millimeter, LengthUnit.Point);
            s.PageSetup.TextColumns[1].Width = LengthUnitConverter.Convert(20, LengthUnit.Millimeter, LengthUnit.Point);
            s.PageSetup.TextColumns[2].Width = LengthUnitConverter.Convert(60, LengthUnit.Millimeter, LengthUnit.Point);
            s.PageSetup.TextColumns[3].Width = LengthUnitConverter.Convert(20, LengthUnit.Millimeter, LengthUnit.Point);

            // Fill our columns by any text.
            string text = "Shrek and Donkey arrive at Farquaad's palace in Duloc, where they end up in a tournament. The winner gets the \"privilege\" of rescuing Fiona so that Farquaad may marry her. ";

            for (int i = 0; i < 22; i++)
                s.Content.End.Insert(text, new CharacterFormat() { FontName = "Arial", Size = 12 });

            (s.Blocks[0] as Paragraph).ParagraphFormat.Alignment = HorizontalAlignment.Justify;

            // Save our document into DOCX format.
            dc.Save(documentPath);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(documentPath) { UseShellExecute = true });
        }
    }
}
How to work with text columns in a document using VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document

Module Sample
    Sub Main()
        TextColumns()
    End Sub
    ''' Get your free 100-day key here:   
    ''' https://sautinsoft.com/start-for-free/
    ''' <summary>
    ''' Working with text columns. 
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/text-columns.php
    ''' </remarks>
    Sub TextColumns()
        Dim documentPath As String = "TextColumns.docx"

        ' Let's create a document with 4 columns.
        Dim dc As New DocumentCore()

        ' Add new section
        Dim s As New Section(dc)
        dc.Sections.Add(s)

        s.PageSetup.PageMargins = New PageMargins() With {
            .Top = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
            .Right = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
            .Bottom = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
            .Left = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point)
        }

        s.PageSetup.TextColumns = New TextColumnCollection(4)
        s.PageSetup.TextColumns.EvenlySpaced = False
        s.PageSetup.TextColumns(0).Width = LengthUnitConverter.Convert(60, LengthUnit.Millimeter, LengthUnit.Point)
        s.PageSetup.TextColumns(1).Width = LengthUnitConverter.Convert(20, LengthUnit.Millimeter, LengthUnit.Point)
        s.PageSetup.TextColumns(2).Width = LengthUnitConverter.Convert(60, LengthUnit.Millimeter, LengthUnit.Point)
        s.PageSetup.TextColumns(3).Width = LengthUnitConverter.Convert(20, LengthUnit.Millimeter, LengthUnit.Point)

        ' Fill our columns by any text.
        Dim text As String = "Shrek and Donkey arrive at Farquaad's palace in Duloc, where they end up in a tournament. The winner gets the ""privilege"" of rescuing Fiona so that Farquaad may marry her. "

        For i As Integer = 0 To 21
            s.Content.End.Insert(text, New CharacterFormat() With {
                .FontName = "Arial",
                .Size = 12
            })
        Next i

        TryCast(s.Blocks(0), Paragraph).ParagraphFormat.Alignment = HorizontalAlignment.Justify

        ' Save our document into DOCX format.
        dc.Save(documentPath)

        ' Open the result for demonstration purposes.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(documentPath) With {.UseShellExecute = True})
    End Sub
End Module
See Also