[Expand]General Information
[Collapse]WinForms Controls
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Map Control
  [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
      Inline Pictures
      Hyperlinks and Bookmarks
      Headers and Footers
      Range Permissions
      Numbered and Bulleted Lists
      Floating Objects (Shapes)
      Text Boxes
      Document Properties
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Spell Checking
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
    Traversing the Document
   [Expand]Visual Elements
    Keyboard Shortcuts
    HTML Tag Support
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Headers and Footers

Each section in the document can have its own set of headers and footers. If no headers or footers are defined for a given section, the headers and footers from the previous section (if any) are used.

To enter a header (footer) editing mode, use the EditPageHeaderCommand or the EditPageFooterCommand commands.

To get access to a header or footer programmatically, you are advised to use the Section.BeginUpdateHeader - Section.EndUpdateHeader or the Section.BeginUpdateFooter - Section.EndUpdateFooter method pairs.


The RichEditControl.Document property gives you access only to the main document body. In particular, it means that you cannot access field or bookmark collections located in the header/footer using this property, but only via BeginUpdateHeader - EndUpdateHeader pair.

The header (or footer) can be different for odd pages, even pages or the first page. Use the Document.DifferentOddAndEvenPages property to distinguish between odd and even pages in the document and the Section.DifferentFirstPage property to display a different header/footer (if any) for the first page of a section.

To switch display modes, you can also use the ToggleDifferentFirstPageCommand and ToggleDifferentOddAndEvenPagesCommand commands.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E5219.

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

To insert fields displaying a current page number or the total number of pages, use the InsertPageNumberFieldCommand and the InsertPageCountFieldCommand commands. You can also insert required fields manually, as described in the How to: Insert Page Numbers in Header or Footer document.

To modify text selected in the header/footer (Document.Selection) or the text at the cursor position (Document.CaretPosition), use the DocumentRange.BeginUpdateDocument or the DocumentPosition.BeginUpdateDocument methods.

Expanded See Also

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