[]
        
(Showing Draft Content)

GrapeCity.Documents.Word.StyleCollection

Class StyleCollection

Namespace
GrapeCity.Documents.Word
Assembly
GcDocs.Word.dll

Represents a collection of built-in and user-defined styles in a document.

public class StyleCollection : IReadOnlyList<Style>, IReadOnlyCollection<Style>, IEnumerable<Style>, IEnumerable
Inheritance
object
StyleCollection
Implements
System.Collections.Generic.IReadOnlyList<T><Style>
System.Collections.Generic.IReadOnlyCollection<T><Style>
System.Collections.Generic.IEnumerable<T><Style>
System.Collections.IEnumerable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

Properties

Count

Gets the number of styles in the collection.

public int Count { get; }

Property Value

int

DefaultFont

Gets document default text formatting.

public FontBase DefaultFont { get; }

Property Value

FontBase

DefaultParagraphFormat

Gets document default paragraph formatting.

public ParagraphFormat DefaultParagraphFormat { get; }

Property Value

ParagraphFormat

DefaultTabStop

Gets or sets the interval (in points) between the default tab stops.

public float DefaultTabStop { get; set; }

Property Value

float

Document

Gets the parent document.

public DocumentBase Document { get; }

Property Value

DocumentBase

this[BuiltInStyleId]

Gets a built-in style by its locale independent identifier.

public Style this[BuiltInStyleId id] { get; }

Parameters

id BuiltInStyleId

The BuiltInStyleId value that specifies the built in style to retrieve.

Property Value

Style

The built-in style.

this[int]

Gets a style by its index.

public Style this[int index] { get; }

Parameters

index int

The index of a style index in the collection.

Property Value

Style

The style with the specified index.

this[string]

Gets a style by name or alias.

public Style this[string name] { get; }

Parameters

name string

A style name or alias.

Property Value

Style

The style with the specified name or alias.

Methods

Add(string, Style)

Creates a new user defined style and adds it to the document.

public Style Add(string name, Style baseStyle)

Parameters

name string

The name of the style to create.

baseStyle Style

The base Style for the new style.

Returns

Style

The newly created style.

Add(string, StyleType)

Creates a new user defined style and adds it to the document.

public Style Add(string name, StyleType type)

Parameters

name string

The name of the style to create.

type StyleType

The StyleType of the style to create.

Returns

Style

The newly created style.

AddLinkedStyle(string, Style)

Adds a pair of linked paragraph and character styles to the collection.

public Style AddLinkedStyle(string name, Style baseStyle = null)

Parameters

name string

The linked style name.

baseStyle Style

A base paragraph or linked style.

Returns

Style

A newly created linked paragraph style.

Contains(string)

Checks whether this collection contains a style with a specified name.

public bool Contains(string name)

Parameters

name string

The style name to check.

Returns

bool

True if the collection contains a style with the specified name or alias, false otherwise.

GetDefaultStyle(StyleType)

Gets the style that is applied to objects that do not explicitly specify a style.

public Style GetDefaultStyle(StyleType type)

Parameters

type StyleType

The style type.

Returns

Style

The default style or null.

SetDefaultStyle(StyleType, Style)

Sets the style that is applied to objects that do not explicitly specify a style.

public void SetDefaultStyle(StyleType type, Style style)

Parameters

type StyleType

The style type.

style Style

The style to set as the default.

TryGetValue(string, out Style)

Tries to get a style from the collection by its name.

public bool TryGetValue(string name, out Style style)

Parameters

name string

The style name.

style Style

When this method returns, contains the style with the specified name or alias if the style was found, or null otherwise.

Returns

bool

True if the style with the specified name or alias was found, false otherwise.