.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

ParagraphStyle.LinkedStyle Property

Gets or sets the linked style for the current style.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v21.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 code sample below demonstrates how to synchronize a paragraph and character style to create a linked style.

ParagraphStyle annotationStyle = document.ParagraphStyles["Annotation"];

document.BeginUpdate();

//Create a new paragraph style
//and set the required settings
annotationStyle = document.ParagraphStyles.CreateNew();
annotationStyle.Name = "Annotation";
annotationStyle.Alignment = ParagraphAlignment.Right;
annotationStyle.LineSpacingMultiplier = 1.5f;
annotationStyle.FirstLineIndentType = ParagraphFirstLineIndent.Hanging;
annotationStyle.FirstLineIndent = 3;
document.ParagraphStyles.Add(annotationStyle);

//Create a new character style and link it
//to the custom paragraph style
CharacterStyle annotationCharStyle = document.CharacterStyles.CreateNew();
annotationCharStyle.Name = "AnnotationChar";
document.CharacterStyles.Add(annotationCharStyle);
annotationCharStyle.LinkedStyle = annotationStyle;

//Specify the style options
annotationCharStyle.Italic = true;
annotationCharStyle.FontSize = 12;
annotationCharStyle.FontName = "Segoe UI";
annotationCharStyle.ForeColor = Color.Gray;
document.EndUpdate();

//Apply the created style to the first paragraph of the annotation
document.Paragraphs[1].Style = annotationStyle;

//Apply the linked style to the range of the annotation's second paragraph
CharacterProperties annotationProperties = document.BeginUpdateCharacters(document.Paragraphs[2].Range);
annotationProperties.Style = annotationCharStyle;
document.EndUpdateCharacters(annotationProperties);

The image below illustrates the result of the code execution.

IMAGE

See Also