Back to Devexpress

CharacterStyleCollection.Add(CharacterStyle) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-characterstylecollection-dot-add-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-characterstyle-x29.md

latest5.3 KB
Original Source

CharacterStyleCollection.Add(CharacterStyle) Method

Add a style to the collection of styles in the current document.

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
void Add(
    CharacterStyle style
)
vb
Sub Add(
    style As CharacterStyle
)

Parameters

NameTypeDescription
styleCharacterStyle

A CharacterStyle class instance representing a character style.

|

Remarks

A collection of styles in the document can be accessed via the Document.CharacterStyles property. To create a new style, use the CharacterStyleCollection.CreateNew method.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Add(CharacterStyle) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Styles.cs#L25

csharp
cstyle.FontName = "Verdana";
    document.CharacterStyles.Add(cstyle);
}

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/StylesActions.cs#L25

csharp
cstyle.FontName = "Verdana";
    document.CharacterStyles.Add(cstyle);
}

winforms-rich-edit-text-formatting/CS/Text Formatting Example/Form1.cs#L146

csharp
annotationCharStyle.Name = "AnnotationChar";
document.CharacterStyles.Add(annotationCharStyle);
annotationCharStyle.LinkedStyle = annotationStyle;

word-document-api-examples/CS/CodeExamples/StylesActions.cs#L40

csharp
// Add the style to the collection of character styles.
    document.CharacterStyles.Add(cstyle);
}

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Styles.vb#L23

vb
cstyle.FontName = "Verdana"
    document.CharacterStyles.Add(cstyle)
End If

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/StylesActions.vb#L21

vb
cstyle.FontName = "Verdana"
    document.CharacterStyles.Add(cstyle)
End If

word-document-api-examples/VB/CodeExamples/StylesActions.vb#L37

vb
' Add the style to the collection of character styles.
    document.CharacterStyles.Add(cstyle)
End If

winforms-rich-edit-text-formatting/VB/Text Formatting Example/Form1.vb#L138

vb
annotationCharStyle.Name = "AnnotationChar"
document.CharacterStyles.Add(annotationCharStyle)
annotationCharStyle.LinkedStyle = annotationStyle

See Also

CharacterStyles

CreateNew()

CharacterStyleCollection Interface

CharacterStyleCollection Members

DevExpress.XtraRichEdit.API.Native Namespace