Back to Devexpress

Rich Text Editor Views

wpf-120518-controls-and-libraries-rich-text-editor-visual-elements-views.md

latest5.5 KB
Original Source

Rich Text Editor Views

  • Nov 26, 2021
  • 2 minutes to read

DXRichEdit can display documents in three different ways depending on the applied document View.

Simple View

Draft View

Print Layout View

End-users can use the Document Views buttons on the View ribbon tab to change the active view. Refer to the Create a Simple Rich Text Editor topic for information on how to provide a Ribbon UI for the DXRichEdit.

The table below describes and compares the available views.

Column ASimple ViewDraft ViewPrint Layout View
APIRichEditControl.ActiveViewType set to Simple
SimpleViewRichEditControl.ActiveViewType set to Draft
DraftViewRichEditControl.ActiveViewType set to PrintLayout
PrintLayoutView
DescriptionSuitable for simple text and web pages. Shows how to the document looks as a website.Used for text formatting. Shows how the document looks on a monitor.Used for complex documents. Shows how the document looks as a printout.
Displayed Editor ElementsNoneHorizontal RulerHorizontal and Vertical Rulers
PagingDocument is not split into pages.Document is not split into pages.Document is divided into pages.
Page LayoutNo page layout options are applied.Only the page width is applied. Multiple columns are displayed as a single column.All page layout options are applied.
Floating Objects PositionMisplacedMisplacedCorrect

View Options

You can use the RichEditControl.ActiveView property to access the current view. The returned RichEditView options allow you to customize the target view.

csharp
richEditControl1.ActiveView.AllowDisplayLineNumbers = true;
richEditControl1.ActiveView.BackColor = System.Drawing.Color.Beige;
vb
richEditControl1.ActiveView.AllowDisplayLineNumbers = True
richEditControl1.ActiveView.BackColor = System.Drawing.Color.Beige

Note

Set the current view’s RichEditView.AdjustColorsToSkins property to true in the RichEditControl.Loaded event handler to adapt the RichEditControl’s text editing surface elements to the current theme.

Use the RichEditControl.LayoutOptions property to access view-specific options.

xaml
<dxre:RichEditControl x:Name="richEditControl1" 
                      CommandBarStyle="Ribbon" 
                      ActiveViewType="PrintLayout">
   <dxre:RichEditControl.LayoutOptions>
       <dxre:DXRichEditLayoutOptions>
           <dxre:DXRichEditLayoutOptions.PrintLayoutViewOptions>
               <dxre:DXRichEditPrintLayoutViewLayoutOptions MatchHorizontalTableIndentsToTextEdge="True" 
                                                            AllowTablesToExtendIntoMargins="True" />
           </dxre:DXRichEditLayoutOptions.PrintLayoutViewOptions>
       </dxre:DXRichEditLayoutOptions>
   </dxre:RichEditControl.LayoutOptions>
</dxre:RichEditControl>

You can control the scrollbars’ and rulers’ visibility for any view. Use the following properties to customize the editing surface appearance:

The code sample below hides all rulers and scrollbars:

xaml
<dxre:RichEditControl x:Name="richEditControl1" VerticalScrollBarVisibility="Hidden" 
                                                    HorizontalScrollBarVisibility="Hidden">
        <dxre:RichEditControl.VerticalRulerOptions>
            <dxre:DXRichEditVerticalRulerOptions Visibility="Hidden"/>
        </dxre:RichEditControl.VerticalRulerOptions>
        <dxre:RichEditControl.HorizontalRulerOptions>
            <dxre:DXRichEditHorizontalRulerOptions Visibility="Hidden"/>
        </dxre:RichEditControl.HorizontalRulerOptions>
    </dxre:RichEditControl>