GemBox.Presentation
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    SlideCollection Class

    Namespace:
    GemBox.Presentation
    Assembly:
    GemBox.Presentation.dll

    Represents a collection of slides contained in the presentation.

    • C#
    • VB.NET
    public sealed class SlideCollection : SlideObjectCollection<Slide>, IList, ICollection, IList<Slide>, ICollection<Slide>, IEnumerable<Slide>, IEnumerable
    Public NotInheritable Class SlideCollection
        Inherits SlideObjectCollection(Of Slide)
        Implements IList, ICollection, IList(Of Slide), ICollection(Of Slide), IEnumerable(Of Slide), IEnumerable
    Inheritance:
    System.Object
    Collection
    Collection<Slide>
    SlideObjectCollection<Slide>
    SlideCollection
    Implements
    System.Collections.IList
    System.Collections.ICollection
    System.Collections.Generic.IList<Slide>
    System.Collections.Generic.ICollection<Slide>
    System.Collections.Generic.IEnumerable<Slide>
    System.Collections.IEnumerable

    Properties

    Count

    Gets the number of Slides contained in the collection.

    • C#
    • VB.NET
    public int Count { get; }
    Public ReadOnly Property Count As Integer
    Property Value
    System.Int32

    The number of Slides contained in the collection.

    Item[Int32]

    Gets or sets the Slide at the specified index.

    • C#
    • VB.NET
    public Slide this[int index] { get; set; }
    Public Property Item(index As Integer) As Slide
    Parameters
    index
    System.Int32

    The zero-based index of the Slide to get or set.

    Property Value
    Slide

    The Slide at the specified index.

    Exceptions
    System.ArgumentOutOfRangeException

    index is less than zero or index is equal to or greater than Count.

    System.ArgumentNullException

    value is null.

    System.ArgumentException

    value is already contained in another SlideCollection or it belongs to another PresentationDocument.

    TextContent

    Gets the text content of the current SlideCollection.

    • C#
    • VB.NET
    public TextRange TextContent { get; }
    Public ReadOnly Property TextContent As TextRange
    Property Value
    TextRange

    The text content of the current SlideCollection.

    Remarks

    For more information, see Find and Replace example.

    Methods

    Add(Slide)

    Adds a Slide to the end of the collection.

    • C#
    • VB.NET
    public void Add(Slide item)
    Public Sub Add(item As Slide)
    Parameters
    item
    Slide

    The Slide to be added to the end of the collection.

    Exceptions
    System.ArgumentNullException

    item is null.

    System.ArgumentException

    item is already contained in another SlideCollection or it belongs to another PresentationDocument.

    AddClone(Slide)

    Adds a clone of the source Slide to the end of the collection. Clone will be formatted using the destination theme.

    • C#
    • VB.NET
    public Slide AddClone(Slide source)
    Public Function AddClone(source As Slide) As Slide
    Parameters
    source
    Slide

    The source Slide that will be cloned.

    Returns
    Slide

    A clone of the source Slide added to the collection.

    Remarks

    Cloning is a process when one or more objects from a presentation are duplicated. Objects can be duplicated to the same or another presentation and to the same or another location (for example, to another slide).

    Cloning methods are available on collection types, such as SlideCollection, DrawingCollection, TextParagraphCollection or TextElementCollection. Exception is the PresentationDocument type that has a Clone() method used to make a deep clone of the entire presentation. Cloning methods available on the collection types have two forms: AddClone(Slide) and InsertClone(Int32, Slide) to append the duplicate to the collection or insert it into a specific location in the collection.

    Objects contained in the presentation can contain references to other objects. For example, Slide contains a reference to its ParentTemplate, Connector can contain a reference to drawings that it connects (BeginConnection and EndConnection), Action can contain a Target to Slide or CustomSlideShow that should be shown when the action is triggered.

    When cloning multiple objects, the desired behavior is to maintain these references in the duplicated objects so that, for example, when Connector is cloned, and later when drawings that it connects are cloned, the duplicated Connector also connects duplicates of the original drawings that are connected.

    This reference mapping between an original object and its duplicate is maintained by the instance of the CloneContext type. CloneContext instance is created with Create(PresentationDocument, PresentationDocument) static method. Each object can be cloned exactly once using the same CloneContext instance. If you want to clone the same object multiple times, each time a new CloneContext instance must be used. CloneContext is the most useful when cloning multiple objects one after another or when you want to change a behavior of the cloning operation.

    Behavior of the cloning operation can be changed by using Set<T>(T, T) method. With this method you can make an explicit mapping between objects and cloning process will respect that mapping. For example, if you are cloning a Slide instance to another PresentationDocument default behavior would be that its parent template LayoutSlide and MasterSlide would also be cloned to another PresentationDocument. This behavior can be changed by making an explicit mapping from the LayoutSlide that is the ParentTemplate of the Slide that will be cloned to some LayoutSlide in the another PresentationDocument that we wish to be a ParentTemplate of the duplicated Slide. Explicit mapping with Set<T>(T, T) method can currently be made between following type (and their derivatives) instances: SlideObject, Drawing, TableStyle and CustomSlideShow.

    Exceptions
    System.ArgumentNullException

    source parameter is null.

    AddClone(Slide, CloneContext)

    Adds a clone of the source Slide to the end of the collection.

    • C#
    • VB.NET
    public Slide AddClone(Slide source, CloneContext context)
    Public Function AddClone(source As Slide, context As CloneContext) As Slide
    Parameters
    source
    Slide

    The source Slide that will be cloned.

    context
    CloneContext

    The context used to maintain reference mapping in multiple cloning operations.

    Returns
    Slide

    A clone of the source Slide added to the collection.

    Remarks

    Cloning is a process when one or more objects from a presentation are duplicated. Objects can be duplicated to the same or another presentation and to the same or another location (for example, to another slide).

    Cloning methods are available on collection types, such as SlideCollection, DrawingCollection, TextParagraphCollection or TextElementCollection. Exception is the PresentationDocument type that has a Clone() method used to make a deep clone of the entire presentation. Cloning methods available on the collection types have two forms: AddClone(Slide) and InsertClone(Int32, Slide) to append the duplicate to the collection or insert it into a specific location in the collection.

    Objects contained in the presentation can contain references to other objects. For example, Slide contains a reference to its ParentTemplate, Connector can contain a reference to drawings that it connects (BeginConnection and EndConnection), Action can contain a Target to Slide or CustomSlideShow that should be shown when the action is triggered.

    When cloning multiple objects, the desired behavior is to maintain these references in the duplicated objects so that, for example, when Connector is cloned, and later when drawings that it connects are cloned, the duplicated Connector also connects duplicates of the original drawings that are connected.

    This reference mapping between an original object and its duplicate is maintained by the instance of the CloneContext type. CloneContext instance is created with Create(PresentationDocument, PresentationDocument) static method. Each object can be cloned exactly once using the same CloneContext instance. If you want to clone the same object multiple times, each time a new CloneContext instance must be used. CloneContext is the most useful when cloning multiple objects one after another or when you want to change a behavior of the cloning operation.

    Behavior of the cloning operation can be changed by using Set<T>(T, T) method. With this method you can make an explicit mapping between objects and cloning process will respect that mapping. For example, if you are cloning a Slide instance to another PresentationDocument default behavior would be that its parent template LayoutSlide and MasterSlide would also be cloned to another PresentationDocument. This behavior can be changed by making an explicit mapping from the LayoutSlide that is the ParentTemplate of the Slide that will be cloned to some LayoutSlide in the another PresentationDocument that we wish to be a ParentTemplate of the duplicated Slide. Explicit mapping with Set<T>(T, T) method can currently be made between following type (and their derivatives) instances: SlideObject, Drawing, TableStyle and CustomSlideShow.

    Exceptions
    System.ArgumentNullException

    source or context parameter is null.

    System.ArgumentException

    source is not associated with the SourcePresentation or the current collection is not associated with the DestinationPresentation of the context.

    AddNew()

    Adds a new Slide to the end of the collection.

    • C#
    • VB.NET
    public Slide AddNew()
    Public Function AddNew As Slide
    Returns
    Slide

    A new Slide with the specified type of layout added to the collection.

    Remarks

    If MasterSlides collection is empty, this method will add a new MasterSlide.

    If LayoutSlides collection of the last MasterSlide from the MasterSlides doesn't contain a LayoutSlide whose type of layout is Title (for a first slide) or TitleAndObject (for a subsequent slides), then a new LayoutSlide with the appropriate type of layout will be added.

    If slide is the first in the presentation, then its parent layout template will have a layout type of Title; otherwise, it will have a layout type of TitleAndObject.

    AddNew(LayoutSlide)

    Adds a new Slide with the specified parent layout template to the end of the collection.

    • C#
    • VB.NET
    public Slide AddNew(LayoutSlide layoutSlide)
    Public Function AddNew(layoutSlide As LayoutSlide) As Slide
    Parameters
    layoutSlide
    LayoutSlide

    The parent layout template of a new Slide.

    Returns
    Slide

    A new Slide with the specified parent layout template added to the collection.

    AddNew(SlideLayoutType)

    Adds a new Slide with a parent template that has a specified type of layout to the end of the collection.

    • C#
    • VB.NET
    public Slide AddNew(SlideLayoutType layoutType)
    Public Function AddNew(layoutType As SlideLayoutType) As Slide
    Parameters
    layoutType
    SlideLayoutType

    The type of layout of a parent template of a new Slide.

    Returns
    Slide

    A new Slide with the specified type of layout added to the collection.

    Remarks

    If MasterSlides collection is empty, this method will add a new MasterSlide.

    If LayoutSlides collection of the last MasterSlide from the MasterSlides doesn't contain a LayoutSlide with the specified layoutType, then a new LayoutSlide with the specified layoutType will be added.

    Clear()

    Removes all Slides from the collection.

    • C#
    • VB.NET
    public void Clear()
    Public Sub Clear

    Contains(Slide)

    Determines whether a Slide is in the collection.

    • C#
    • VB.NET
    public bool Contains(Slide item)
    Public Function Contains(item As Slide) As Boolean
    Parameters
    item
    Slide

    The Slide to locate in the collection.

    Returns
    System.Boolean

    true if item is found in the collection; otherwise, false.

    Exceptions
    System.ArgumentNullException

    item is null.

    GetEnumerator()

    Returns an enumerator that iterates through the SlideCollection.

    • C#
    • VB.NET
    public IEnumerator<Slide> GetEnumerator()
    Public Function GetEnumerator As IEnumerator(Of Slide)
    Returns
    System.Collections.Generic.IEnumerator<Slide>

    An System.Collections.Generic.IEnumerator<T> for the collection.

    IndexOf(Slide)

    Searches for the specified Slide and returns the zero-based index of the first occurrence within the entire collection.

    • C#
    • VB.NET
    public int IndexOf(Slide item)
    Public Function IndexOf(item As Slide) As Integer
    Parameters
    item
    Slide

    The Slide to locate in the collection.

    Returns
    System.Int32

    The zero-based index of the first occurrence of item within the entire collection, if found; otherwise, -1.

    Insert(Int32, Slide)

    Inserts a Slide to the collection at the specified index.

    • C#
    • VB.NET
    public void Insert(int index, Slide item)
    Public Sub Insert(index As Integer, item As Slide)
    Parameters
    index
    System.Int32

    The zero-based index at which Slide should be inserted.

    item
    Slide

    The Slide to insert into the collection.

    Exceptions
    System.ArgumentOutOfRangeException

    index is less than zero or index is equal to or greater than Count.

    System.ArgumentNullException

    item is null.

    System.ArgumentException

    item is already contained in another SlideCollection or it belongs to another PresentationDocument.

    InsertClone(Int32, Slide)

    Inserts a clone of the source Slide to the collection at the specified index. Clone will be formatted using the destination theme.

    • C#
    • VB.NET
    public Slide InsertClone(int index, Slide source)
    Public Function InsertClone(index As Integer, source As Slide) As Slide
    Parameters
    index
    System.Int32

    The zero-based index at which clone of the source Slide should be inserted.

    source
    Slide

    The source Slide that will be cloned.

    Returns
    Slide

    A clone of the source Slide inserted to the collection.

    Remarks

    Cloning is a process when one or more objects from a presentation are duplicated. Objects can be duplicated to the same or another presentation and to the same or another location (for example, to another slide).

    Cloning methods are available on collection types, such as SlideCollection, DrawingCollection, TextParagraphCollection or TextElementCollection. Exception is the PresentationDocument type that has a Clone() method used to make a deep clone of the entire presentation. Cloning methods available on the collection types have two forms: AddClone(Slide) and InsertClone(Int32, Slide) to append the duplicate to the collection or insert it into a specific location in the collection.

    Objects contained in the presentation can contain references to other objects. For example, Slide contains a reference to its ParentTemplate, Connector can contain a reference to drawings that it connects (BeginConnection and EndConnection), Action can contain a Target to Slide or CustomSlideShow that should be shown when the action is triggered.

    When cloning multiple objects, the desired behavior is to maintain these references in the duplicated objects so that, for example, when Connector is cloned, and later when drawings that it connects are cloned, the duplicated Connector also connects duplicates of the original drawings that are connected.

    This reference mapping between an original object and its duplicate is maintained by the instance of the CloneContext type. CloneContext instance is created with Create(PresentationDocument, PresentationDocument) static method. Each object can be cloned exactly once using the same CloneContext instance. If you want to clone the same object multiple times, each time a new CloneContext instance must be used. CloneContext is the most useful when cloning multiple objects one after another or when you want to change a behavior of the cloning operation.

    Behavior of the cloning operation can be changed by using Set<T>(T, T) method. With this method you can make an explicit mapping between objects and cloning process will respect that mapping. For example, if you are cloning a Slide instance to another PresentationDocument default behavior would be that its parent template LayoutSlide and MasterSlide would also be cloned to another PresentationDocument. This behavior can be changed by making an explicit mapping from the LayoutSlide that is the ParentTemplate of the Slide that will be cloned to some LayoutSlide in the another PresentationDocument that we wish to be a ParentTemplate of the duplicated Slide. Explicit mapping with Set<T>(T, T) method can currently be made between following type (and their derivatives) instances: SlideObject, Drawing, TableStyle and CustomSlideShow.

    Exceptions
    System.ArgumentNullException

    source parameter is null.

    InsertClone(Int32, Slide, CloneContext)

    Inserts a clone of the source Slide to the collection at the specified index.

    • C#
    • VB.NET
    public Slide InsertClone(int index, Slide source, CloneContext context)
    Public Function InsertClone(index As Integer, source As Slide, context As CloneContext) As Slide
    Parameters
    index
    System.Int32

    The zero-based index at which clone of the source Slide should be inserted.

    source
    Slide

    The source Slide that will be cloned.

    context
    CloneContext

    The context used to maintain reference mapping in multiple cloning operations.

    Returns
    Slide

    A clone of the source Slide inserted to the collection.

    Remarks

    Cloning is a process when one or more objects from a presentation are duplicated. Objects can be duplicated to the same or another presentation and to the same or another location (for example, to another slide).

    Cloning methods are available on collection types, such as SlideCollection, DrawingCollection, TextParagraphCollection or TextElementCollection. Exception is the PresentationDocument type that has a Clone() method used to make a deep clone of the entire presentation. Cloning methods available on the collection types have two forms: AddClone(Slide) and InsertClone(Int32, Slide) to append the duplicate to the collection or insert it into a specific location in the collection.

    Objects contained in the presentation can contain references to other objects. For example, Slide contains a reference to its ParentTemplate, Connector can contain a reference to drawings that it connects (BeginConnection and EndConnection), Action can contain a Target to Slide or CustomSlideShow that should be shown when the action is triggered.

    When cloning multiple objects, the desired behavior is to maintain these references in the duplicated objects so that, for example, when Connector is cloned, and later when drawings that it connects are cloned, the duplicated Connector also connects duplicates of the original drawings that are connected.

    This reference mapping between an original object and its duplicate is maintained by the instance of the CloneContext type. CloneContext instance is created with Create(PresentationDocument, PresentationDocument) static method. Each object can be cloned exactly once using the same CloneContext instance. If you want to clone the same object multiple times, each time a new CloneContext instance must be used. CloneContext is the most useful when cloning multiple objects one after another or when you want to change a behavior of the cloning operation.

    Behavior of the cloning operation can be changed by using Set<T>(T, T) method. With this method you can make an explicit mapping between objects and cloning process will respect that mapping. For example, if you are cloning a Slide instance to another PresentationDocument default behavior would be that its parent template LayoutSlide and MasterSlide would also be cloned to another PresentationDocument. This behavior can be changed by making an explicit mapping from the LayoutSlide that is the ParentTemplate of the Slide that will be cloned to some LayoutSlide in the another PresentationDocument that we wish to be a ParentTemplate of the duplicated Slide. Explicit mapping with Set<T>(T, T) method can currently be made between following type (and their derivatives) instances: SlideObject, Drawing, TableStyle and CustomSlideShow.

    Exceptions
    System.ArgumentNullException

    source or context parameter is null.

    System.ArgumentException

    source is not associated with the SourcePresentation or the current collection is not associated with the DestinationPresentation of the context.

    InsertNew(Int32)

    Inserts a new Slide to the collection at the specified index.

    • C#
    • VB.NET
    public Slide InsertNew(int index)
    Public Function InsertNew(index As Integer) As Slide
    Parameters
    index
    System.Int32

    The zero-based index at which new Slide should be inserted.

    Returns
    Slide

    A new Slide inserted to the collection.

    Remarks

    If MasterSlides collection is empty, this method will add a new MasterSlide.

    If LayoutSlides collection of the last MasterSlide from the MasterSlides doesn't contain a LayoutSlide whose type of layout is Title (for a first slide) or TitleAndObject (for a subsequent slides), then a new LayoutSlide with the appropriate type of layout will be added.

    If slide is the first in the presentation, then its parent layout template will have a layout type of Title; otherwise, it will have a layout type of TitleAndObject.

    Exceptions
    System.ArgumentOutOfRangeException

    index is less than zero or index is equal to or greater than Count.

    InsertNew(Int32, LayoutSlide)

    Inserts a new Slide with the specified parent layout template to the collection at the specified index.

    • C#
    • VB.NET
    public Slide InsertNew(int index, LayoutSlide layoutSlide)
    Public Function InsertNew(index As Integer, layoutSlide As LayoutSlide) As Slide
    Parameters
    index
    System.Int32

    The zero-based index at which new Slide should be inserted.

    layoutSlide
    LayoutSlide

    The parent layout template of a new Slide.

    Returns
    Slide

    A new Slide with the specified parent layout template inserted to the collection.

    Exceptions
    System.ArgumentOutOfRangeException

    index is less than zero or index is equal to or greater than Count.

    InsertNew(Int32, SlideLayoutType)

    Inserts a new Slide with a parent template that has a specified type of layout to the collection at the specified index.

    • C#
    • VB.NET
    public Slide InsertNew(int index, SlideLayoutType layoutType)
    Public Function InsertNew(index As Integer, layoutType As SlideLayoutType) As Slide
    Parameters
    index
    System.Int32

    The zero-based index at which new Slide should be inserted.

    layoutType
    SlideLayoutType

    The type of layout of a parent template of a new Slide.

    Returns
    Slide

    A new Slide with the specified type of layout inserted to the collection.

    Remarks

    If MasterSlides collection is empty, this method will add a new MasterSlide.

    If LayoutSlides collection of the last MasterSlide from the MasterSlides doesn't contain a LayoutSlide with the specified layoutType, then a new LayoutSlide with the specified layoutType will be added.

    Exceptions
    System.ArgumentOutOfRangeException

    index is less than zero or index is equal to or greater than Count.

    Remove(Slide)

    Removes the first occurrence of a specific Slide from the collection.

    • C#
    • VB.NET
    public bool Remove(Slide item)
    Public Function Remove(item As Slide) As Boolean
    Parameters
    item
    Slide

    The Slide to remove from the collection.

    Returns
    System.Boolean

    true if item is successfully removed; otherwise, false. This method also returns false if item was not found in the original collection.

    RemoveAt(Int32)

    Removes the Slide at the specified index of the collection.

    • C#
    • VB.NET
    public void RemoveAt(int index)
    Public Sub RemoveAt(index As Integer)
    Parameters
    index
    System.Int32

    The zero-based index of the Slide to remove.

    Exceptions
    System.ArgumentOutOfRangeException

    index is less than zero or index is equal to or greater than Count.

    Implements

    System.Collections.IList
    System.Collections.ICollection
    System.Collections.Generic.IList<T>
    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable

    Examples

    Slides Example
    Find and Replace example
    Cloning Example

    See Also

    Slides
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.