StyleCollectionItem Property (StyleIdentifier)

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

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public Style this[
	StyleIdentifier sti
] { get; }

Parameters

sti
Type: Aspose.WordsStyleIdentifier
A StyleIdentifier value that specifies the built in style to retrieve.

Property Value

Type: Style
Remarks

When accessing a style that does not yet exist, automatically creates it.

Examples
Shows how to add a Style to a StyleCollection.
Document doc = new Document();

// New documents come with a collection of default styles that can be applied to paragraphs
StyleCollection styles = doc.Styles;
Assert.AreEqual(4, styles.Count);

// We can set default parameters for new styles that will be added to the collection from now on
styles.DefaultFont.Name = "Courier New";
styles.DefaultParagraphFormat.FirstLineIndent = 15.0;

styles.Add(StyleType.Paragraph, "MyStyle");

// Styles within the collection can be referenced either by index or name
Assert.AreEqual("Courier New", styles[4].Font.Name);
Assert.AreEqual(15.0, styles["MyStyle"].ParagraphFormat.FirstLineIndent);
See Also