Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

CharacterStyle Interface

Exposes methods and characteristics of a character style in a document.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v19.1.Core.dll

Declaration

[ComVisible(true)]
public interface CharacterStyle :
    CharacterPropertiesBase

Remarks

A style pertains to a document. It belongs to a particular document model, and you cannot add a style object from the style collection of one document to the style collection of another.

The following code snippet creates a new character style via the CharacterStyleCollection.CreateNew method, specifies style settings, adds it to the document style collection and applies the style to the specified range.

document.LoadDocument("Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml)
Dim cstyle As CharacterStyle = document.CharacterStyles("MyCStyle")
If cstyle Is Nothing Then
    cstyle = document.CharacterStyles.CreateNew()
    cstyle.Name = "MyCStyle"
    cstyle.Parent = document.CharacterStyles("Default Paragraph Font")
    cstyle.ForeColor = System.Drawing.Color.DarkOrange
    cstyle.Strikeout = StrikeoutType.Double
    cstyle.FontName = "Verdana"
    document.CharacterStyles.Add(cstyle)
End If
Dim myRange As DocumentRange = document.Paragraphs(0).Range
Dim charProps As CharacterProperties = document.BeginUpdateCharacters(myRange)
charProps.Style = cstyle
document.EndUpdateCharacters(charProps)
See Also