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: 4.0.10.28 (4.0.10.28)
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 propertyCount (Inherited from ReadOnlyCollectionTextColumn.)
Public propertyCode exampleEvenlySpaced
Gets or sets a value indicating whether all text columns have equal width and are evenly spaced.
Public propertyItem
Gets the element at the specified index.
(Inherited from ReadOnlyCollectionTextColumn.)
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
Methods
  NameDescription
Public methodContains (Inherited from ReadOnlyCollectionTextColumn.)
Public methodCopyTo (Inherited from ReadOnlyCollectionTextColumn.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetEnumerator (Inherited from ReadOnlyCollectionTextColumn.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIndexOf (Inherited from ReadOnlyCollectionTextColumn.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodICollectionTAdd (Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodIListAdd
Adds an item to the IList. This implementation always throws NotSupportedException.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodICollectionTClear (Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodIListClear
Removes all items from the IList. This implementation always throws NotSupportedException.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodIListContains
Determines whether the IList contains a specific value.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodICollectionCopyTo
Copies the elements of the ICollection to an Array, starting at a particular Array index.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodIEnumerableGetEnumerator
Returns an enumerator that iterates through a collection.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodIListIndexOf
Determines the index of a specific item in the IList.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodIListTInsert (Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodIListInsert
Inserts an item to the IList at the specified index. This implementation always throws NotSupportedException.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate propertyIListIsFixedSize
Gets a value indicating whether the IList has a fixed size.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate propertyICollectionTIsReadOnly (Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate propertyIListIsReadOnly
Gets a value indicating whether the IList is read-only.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate propertyICollectionIsSynchronized
Gets a value indicating whether access to the ICollection is synchronized (thread safe).
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate propertyIListTItem
Gets the element at the specified index. An NotSupportedException occurs if you try to set the item at the specified index.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate propertyIListItem
Gets the element at the specified index. A NotSupportedException occurs if you try to set the item at the specified index.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodICollectionTRemove (Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodIListRemove
Removes the first occurrence of a specific object from the IList. This implementation always throws NotSupportedException.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodIListTRemoveAt (Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate methodIListRemoveAt
Removes the IList item at the specified index. This implementation always throws NotSupportedException.
(Inherited from ReadOnlyCollectionTextColumn.)
Explicit interface implementationPrivate propertyICollectionSyncRoot
Gets an object that can be used to synchronize access to the ICollection.
(Inherited from ReadOnlyCollectionTextColumn.)
Top
Examples
How to work with text columns in a document using C#
using SautinSoft.Document;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            TextColumns();
        }

        /// <summary>
        /// Working with text columns. 
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/examples/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

    ''' <summary>
    ''' Working with text columns. 
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/examples/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