.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
A newer version of this page is available. Switch to the current version.

ParagraphStyle.LinkedStyle Property

Gets or sets the linked style for the current style.

Namespace: DevExpress.XtraRichEdit.API.Native

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

Declaration

CharacterStyle LinkedStyle { get; set; }

Property Value

Type Description
CharacterStyle

A ParagraphStyle object representing a paragraph style linked to a current style

Remarks

A linked style can act as a paragraph style or a character style, depending on the range to which it is applied.

If a linked style is applied to a selection which does not include an entire paragraph, the selected text is formatted with the character formatting settings of the linked styles.

If a selection includes an entire paragraph, both character and paragraph formatting settings are applied.

If a selection is just a caret position and contains no characters, the linked style behaves like a paragraph style.

You should specify the LinkedStyle property only once, for one of the linked styles.

NOTE

Assigning a style via the LinkedStyle property results in overwriting the corresponding settings of the style to which the style becomes linked. So you are advised to link styles first, and specify their settings afterwards.

The following code snippet demonstrates how to create linked styles.

document.BeginUpdate()
document.AppendText("Line One" & vbLf & "Line Two" & vbLf & "Line Three")
document.EndUpdate()

'Create new paragraph style
Dim lstyle As ParagraphStyle = document.ParagraphStyles("MyLinkedStyle")
If lstyle Is Nothing Then
    document.BeginUpdate()
    lstyle = document.ParagraphStyles.CreateNew()
    lstyle.Name = "MyLinkedStyle"
    lstyle.LineSpacingType = ParagraphLineSpacing.Double
    lstyle.Alignment = ParagraphAlignment.Center
    document.ParagraphStyles.Add(lstyle)

    Dim lcstyle As CharacterStyle = document.CharacterStyles.CreateNew()
    lcstyle.Name = "MyLinkedCStyle"
    document.CharacterStyles.Add(lcstyle)
    lcstyle.LinkedStyle = lstyle

    lcstyle.ForeColor = System.Drawing.Color.DarkGreen
    lcstyle.Strikeout = StrikeoutType.Single
    lcstyle.FontSize = 24
    document.EndUpdate()

    'Apply created styles 
    'to the text range and to the entire paragraph
    document.Paragraphs(1).Style = lstyle

    Dim myRange As DocumentRange = document.Paragraphs(0).Range
    Dim charProps As CharacterProperties = document.BeginUpdateCharacters(myRange)
    charProps.Style = lcstyle
    document.EndUpdateCharacters(charProps)
End If
See Also