Skip to main content
A newer version of this page is available. .

How to: Mark Text as Hidden and Display Hidden Text in the DXRichEdit

The following example describes how to mark text as hidden and display hidden text in the RichEditControl.

Mark Text as Hidden

  1. Use the Range property to get the range occupied by the target text.

    Refer to the How to: Select Text Programmatically example for information on how to select text in code, and the How To: Obtain Specific Document Part topic for details on how to obtain specific document part.

  2. Call the SubDocument.BeginUpdateCharacters method to update the character properties. Pass the retrieved range to the method as a range parameter.
  3. Set the CharacterPropertiesBase.Hidden property to true to hide the text.
  4. Call the SubDocument.EndUpdateCharacters method to finalize the update.

The code sample below hides the third document paragraph.

DocumentRange hiddenRange = richEditControl1.Document.Paragraphs[2].Range;
CharacterProperties hiddenTextProperties = richEditControl1.Document.BeginUpdateCharacters(hiddenRange);
hiddenTextProperties.Hidden = true;
richEditControl1.Document.EndUpdateCharacters(hiddenTextProperties);

Display Hidden Text

Set the DXRichEditFormattingMarkVisibilityOptions.HiddenText property to RichEditFormattingMarkVisibility.Visible to display hidden text in the RichEditControl. Access the property using the richEditControl.Options.FormattingMarkVisibility notation.

<dxre:RichEditControl x:Name="richEditControl1" CommandBarStyle="Ribbon">
  <dxre:RichEditControl.FormattingMarkVisibilityOptions>
           <dxre:DXRichEditFormattingMarkVisibilityOptions HiddenText="Visible"/>
  </dxre:RichEditControl.FormattingMarkVisibilityOptions>
</dxre:RichEditControl>

The image below illustrates how the RichEditControl displays hidden text.

XtraRichEdit_Examples_ShowHiddenSymbols