officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-8bedadd4.md
Exposes methods and characteristics of a character style in a document.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
[ComVisible(true)]
public interface CharacterStyle :
CharacterPropertiesBase
<ComVisible(True)>
Public Interface CharacterStyle
Inherits CharacterPropertiesBase
The following members return CharacterStyle objects:
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.
Document document = server.Document;
server.LoadDocument("Documents\\Grimm.docx", DocumentFormat.Docx);
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);
Dim document As Document = server.Document
server.LoadDocument("Documents\Grimm.docx", DocumentFormat.Docx)
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