Click or drag to resize

ElementCollection Class

Represents a base non-generic class for Element collections.
Inheritance Hierarchy

Namespace:  SautinSoft.Document
Assembly:  SautinSoft.Document (in SautinSoft.Document.dll) Version: 3.8.6.28 (3.8.6.28)
Syntax
public abstract class ElementCollection : IList, 
	ICollection, IEnumerable

The ElementCollection type exposes the following members.

Properties
  NameDescription
Public propertyContent
Gets the ContentRange of this collection.
Public propertyCount
Gets the number of elements contained in this collection.
Public propertyItem
Gets the Element at the specified index.
Public propertySupportedElementTypes
Gets a sequence of ElementTypes that can be contained in this collection.
Top
Methods
  NameDescription
Public methodClear
Removes all elements from this collection.
Public methodCopyTo
Copies the entire collection to an Array, starting at a particular Array index.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetEnumerator
Returns an enumerator that iterates through a collection.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodCode exampleRemoveAt
Removes the element at the specified index.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodIListAdd
Adds an item to the IList.
Explicit interface implementationPrivate methodIListContains
Determines whether the IList contains a specific value.
Explicit interface implementationPrivate methodICollectionCopyTo
Copies the elements of the ICollection to an Array, starting at a particular Array index.
Explicit interface implementationPrivate methodIEnumerableGetEnumerator
Returns an enumerator that iterates through a collection.
Explicit interface implementationPrivate methodIListIndexOf
Determines the index of a specific item in the IList.
Explicit interface implementationPrivate methodIListInsert
Inserts an item to the IList at the specified index.
Explicit interface implementationPrivate propertyIListIsFixedSize
Gets a value indicating whether the IList has a fixed size.
Explicit interface implementationPrivate propertyIListIsReadOnly
Gets a value indicating whether the IList is read-only.
Explicit interface implementationPrivate propertyICollectionIsSynchronized
Gets a value indicating whether access to the ICollection is synchronized (thread safe).
Explicit interface implementationPrivate propertyIListItem
Gets or sets the element at the specified index.
Explicit interface implementationPrivate methodIListRemove
Removes the first occurrence of a specific object from the IList.
Explicit interface implementationPrivate methodIListRemoveAt
Removes the IList item at the specified index.
Explicit interface implementationPrivate propertyICollectionSyncRoot
Gets an object that can be used to synchronize access to the ICollection.
Top
Examples
Manipulation with ElementCollection. Split 1st Paragraph by separate Runs and insert each Run into a new Paragraph in C#
using System.IO;
using System.Linq;
using SautinSoft.Document;

namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            Manipulation();
        }
        /// <summary>
        /// Manipulation with ElementCollection. Split 1st Paragraph by separate Runs and insert each Run into a new Paragraph.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/examples/elementcollection-manipulation.php
        /// </remarks>
        static void Manipulation()
        {
            string filePath = @"..\..\example.docx";
            DocumentCore dc = DocumentCore.Load(filePath);
            string filePathResult = @"Result-file.pdf";
            Section section = dc.Sections[0];
            Paragraph paragraph = section.Blocks[0] as Paragraph;
            for (int i = 1; i < paragraph.Inlines.Count ; )
            {
                Inline inline = paragraph.Inlines[i];
                paragraph.Inlines.RemoveAt(1);
                section.Blocks.Add(new Paragraph(dc, inline));
            }
            dc.Save(filePathResult);
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePathResult) { UseShellExecute = true });
        }
    }
}
Manipulation with ElementCollection. Split 1st Paragraph by separate Runs and insert each Run into a new Paragraph in VB.Net
Imports System.IO
Imports System.Linq
Imports SautinSoft.Document

Module Sample
    Sub Main()
        Manipulation()
    End Sub

    ''' <summary>
    ''' Manipulation with ElementCollection. Split 1st Paragraph by separate Runs and insert each Run into a new Paragraph.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/examples/elementcollection-manipulation.php
    ''' </remarks>
    Sub Manipulation()
        Dim filePath As String = "..\example.docx"
        Dim dc As DocumentCore = DocumentCore.Load(filePath)
        Dim filePathResult As String = "Result-file.pdf"
        Dim section As Section = dc.Sections(0)
        Dim paragraph As Paragraph = TryCast(section.Blocks(0), Paragraph)
        Dim i As Integer = 1
        Do While i < paragraph.Inlines.Count
            Dim inline As Inline = paragraph.Inlines(i)
            paragraph.Inlines.RemoveAt(1)
            section.Blocks.Add(New Paragraph(dc, inline))
        Loop
        dc.Save(filePathResult)
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePathResult) With {.UseShellExecute = True})
    End Sub
End Module
See Also