[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
      Floating Objects
      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
    Traversing the Document
   [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]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]CodeRush
[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 header (footer) editing mode, use the EditPageHeaderCommand or the EditPageFooterCommand commands.

You can also use the Section.BeginUpdateHeader - Section.EndUpdateHeader or the Section.BeginUpdateFooter - Section.EndUpdateFooter method pairs, to create and modify the header/footer programmatically.

Show Me

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

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 are inserted into the document and the Section.EndUpdateHeader is called to finalize the modification.

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, use the ToggleDifferentFirstPageCommand and ToggleDifferentOddAndEvenPagesCommand commands.

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.

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