Back to Devexpress

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

wpf-120502-controls-and-libraries-rich-text-editor-examples-text-how-to-mark-text-as-hidden-and-display-hidden-text-in-the-dxrichedit.md

latest2.6 KB
Original Source

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

  • Aug 21, 2018

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.

  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.

csharp
DocumentRange hiddenRange = richEditControl1.Document.Paragraphs[2].Range;
CharacterProperties hiddenTextProperties = richEditControl1.Document.BeginUpdateCharacters(hiddenRange);
hiddenTextProperties.Hidden = true;
richEditControl1.Document.EndUpdateCharacters(hiddenTextProperties);
vb
Dim hiddenRange As DocumentRange = richEditControl1.Document.Paragraphs(2).Range
Dim hiddenTextProperties As CharacterProperties = 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.

xaml
<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.