[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Collapse]RichEditControl Document
    [Expand]Document Structure
    [Collapse]Document Elements
      Positions and Ranges
      Characters
      Paragraphs
      Inline Pictures
      Hyperlinks and Bookmarks
      Headers and Footers
      Tables
      Range Permissions
      Sections
      Styles
      Lists
      Shapes
      Text Boxes
      Comments
      Checkboxes
      Document Properties
   [Expand]Fields
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Printing
    AutoCorrect
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
   [Expand]Visual Elements
    Services
    Events
    Commands
    HTML Tag Support
   [Expand]Examples
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Headers and Footers

The DXRichEdit provides the following approaches to manage document headers and footers:

Expanded Headers and Footers in the User Interface

End-users can use the Insert ribbon tab to edit a section's header or footer. If the document already has headers or footers, double-click the corresponding page area to activate the header or footer.

The Header and Footer Tools tab is available when you open a header or footer. This tab allows end-users to navigate through document's headers and footers, set or break the link between two section's headers or footers, specify different settings for the first page or distinguish between odd and even pages.

Handle the RichEditControl.StartHeaderFooterEditing event to determine when an end-user enters the header/footer editing mode. The RichEditControl.FinishHeaderFooterEditing occurs when they close the editing mode.

Tip

Set the DXRichEditDocumentCapabilitiesOptions.HeadersFooters to DocumentCapability.Disabled or DocumentCapability.Hidden to restrict end-users from editing headers or footers.

Expanded Manage Headers and Footers in Code

Each section has a header and footer. If a section does not have headers or footers, the previous sections' headers and footers (if any) are used.

Expanded Create Headers and Footers

Commands

The DXRichEdit provides the following commands to activate headers and footers:

Command Description
EditPageHeaderCommand A command to activate the page header and begin editing.
EditPageFooterCommand A command to activate the page footer, and begin editing.

API

You can use the Section.BeginUpdateHeader and Section.BeginUpdateFooter methods to access the section's header or footer. Pass one of the HeaderFooterType enumeration values as a type parameter to define the header or footer's type. Use the following API to access headers and footers in code:

API

Description

Section.BeginUpdateHeader

Section.BeginUpdateFooter

Accesses the document's header or footer.

Section.HasHeader

Section.HasFooter

Checks whether the given section contains a header or footer.

Section.EndUpdateHeader

Section.EndUpdateFooter

Finalizes the header or footer update.

The code sample below creates an empty document header:

Expanded Modify Headers and Footers

Commands

Execute one of the following commands to move between headers or footers and change their options:

Command Description
GoToNextPageHeaderFooterCommand Navigates to the next page header/footer in edit mode.
GoToPageHeaderCommand Navigates to the page header from the page footer in edit mode.
GoToPageFooterCommand Navigates to the page footer from the page header in edit mode.
GoToPreviousPageHeaderFooterCommand Navigates to the previous page header/footer in edit mode.
ToggleDifferentFirstPageCommand Changes the header/footer edit mode. Allows you to create a different header or footer for the first page of a document or section.
ToggleHeaderFooterLinkToPreviousCommand Links a header/footer to the previous section, so it has the same content.
ToggleDifferentOddAndEvenPagesCommand Changes the header/footer edit mode. Allows you to create a different header or footer for odd and even pages of a document or section.

API

Headers' and footers' content are in a separate SubDocument. Call the Section.BeginUpdateHeader or Section.BeginUpdateFooter method to access the header's or footer's content. Headers and footers can contain inline images, floating objects (textboxes or images) and tables. You cannot add comments to headers' or footers' text.

Note

The header or footer fields belong to a separate FieldCollection. Retrieve the header's or footer's SubDocument and call the FieldCollection.Update method to update these fields.

The following code snippet opens the first section's header for editing. The header type is HeaderFooterType.First, so it is displayed for the first page only if the corresponding mode is enabled (use the Section.DifferentFirstPage property). Then, the text string and a PAGE field are inserted and the Section.EndUpdateHeader method is called to finalize the modification.

Tip

Call the Document.ChangeActiveDocument method to switch to the header's or footer's SubDocument. This step allows you to select text ranges or place the caret in the header or footer. Call the Document.ChangeActiveDocument again to switch to the main document body.

Use the following API to change header/footer options in code:

API

Description

Section.DifferentFirstPage

Defines whether to display a different header/footer (if any) for the section's first page.

Document.DifferentOddAndEvenPages

Specifies whether the even-numbered pages should have a different header or footer than odd-numbered pages.

Section.LinkHeaderToNext

Section.LinkFooterToNext

Links the current section's header or footer to the next section's header or footer.

Section.LinkHeaderToPrevious

Section.LinkFooterToPrevious

Links the current section's header or footer to the previous section's header or footer.

Section.IsHeaderLinkedToNext

Section.IsFooterLinkedToNext

Checks whether the current section's header or footer is linked to the next section's header or footer.

Section.IsHeaderLinkedToPrevious

Section.IsFooterLinkedToPrevious

Checks whether the current section's header or footer is linked to the previous section's header or footer.

Section.UnlinkHeaderFromNext

Section.UnlinkFooterFromNext

Unlinks the current section's header or footer from the next section's header or footer.

Section.UnlinkHeaderFromPrevious

Section.UnlinkFooterFromPrevious

Unlinks the current section's header or footer from the next section's header or footer.

Expanded See Also

Is this topic helpful?​​​​​​​