Skip to main content

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

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 FormattingMarkVisibilityOptions.HiddenText property to RichEditFormattingMarkVisibility.Visible to display hidden text in the RichEditControl. Access the property using the richEditControl.Options.FormattingMarkVisibility notation.

richEditControl1.Options.FormattingMarkVisibility.HiddenText = RichEditFormattingMarkVisibility.Visible;

The image below illustrates how the RichEditControl displays hidden text.

XtraRichEdit_Examples_ShowHiddenSymbols