Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

CharacterStyle Interface

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

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core

#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.

View Example

Document document = server.Document;
server.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml);
CharacterStyle cstyle = document.CharacterStyles["MyCStyle"];
if (cstyle == null)
{
    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);
}
DocumentRange myRange = document.Paragraphs[0].Range;
CharacterProperties charProps =
    document.BeginUpdateCharacters(myRange);
charProps.Style = cstyle;
document.EndUpdateCharacters(charProps);
See Also