Log In
[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]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Map Control
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
   [Expand]Getting Started
   [Expand]RichEditControl Document
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Spell Checking
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
    Traversing the Document
   [Expand]Visual Elements
   [Expand]Member Tables
    Keyboard Shortcuts
    HTML Tag Interpretation
    [Expand]Text Boxes
    [Expand]Search and Replace
    [Expand]Mail Merge
    [Expand]Spell Check
    [Expand]User Interface Customization
      How to: Insert Bookmark or Hyperlink
      How to: Create, Edit and Delete Comments
      How to: Specify Document Properties
      How to: Create and Modify Header
  [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]Document Server
[Expand]Report Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Create and Modify Header

The following article explains how to create and modify a document header.

Expanded Create a Header

To create a document header, select the section where it is going to be located. To check whether this section already has a header, use the Section.HasHeader property.

The Section.BeginUpdateHeader method is used to start the process. It also creates a new header of the specified HeaderFooterType type. If the type is not specified, the HeaderFooterType.Primary header will be created.

To work with the document header, use the Document.ChangeActiveDocument method. Note that if this method is not used, the wrong header can be selected and the follow-up actions may fail.

Use the Section.EndUpdateHeader to finish working with the header.

Show Me

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

Expanded Modify Header

To modify the header, specify the section to which the header belongs and use the Section.BeginUpdateHeader method to open it for modifying. To insert additional content to the header, use the SubDocument.InsertText or ShapeCollection.InsertPicture method. Use the Section.EndUpdateHeader to complete the modification.

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.

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