How to: Create and Modify Header
- 2 minutes to read
The following article explains how to create and modify a document header.
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.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/wpf-richedit-document-api-t213968.
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.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/wpf-richedit-document-api-t213968.