Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [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]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Collapse]Rich Text Editor
    Overview
   [Expand]Getting Started
   [Collapse]Fundamentals
    [Expand]RichEditControl
    [Collapse]Document
      Document Model
      Document Layout
      Positions and Ranges
      Characters
      Paragraphs
      Inline Pictures
      Document Fields
      Hyperlinks and Bookmarks
      Headers and Footers
      Tables
      Range Permissions
      Sections
      Styles
      Numbered and Bulleted Lists
      Floating Objects (Shapes)
      Text Boxes
      Comments
      Document Properties
     Supported Document Formats
    [Expand]Fields
     Commands
     Services
     Layout API
     Product Class Structure
     Default Keyboard Shortcuts
     Measure Units
     HTML Tag Interpretation
   [Expand]Concepts
   [Expand]Visual Elements
   [Expand]Examples
   [Expand]Member Tables
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [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]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[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.

Note

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

How would you rate this topic?​​​​​​​