officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-section-dot-hasheader-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-headerfootertype-x29.md
Gets whether a section has a header of the specified type.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
bool HasHeader(
HeaderFooterType type
)
Function HasHeader(
type As HeaderFooterType
) As Boolean
| Name | Type | Description |
|---|---|---|
| type | HeaderFooterType |
A HeaderFooterType enumeration value specifying the header type.
|
| Type | Description |
|---|---|
| Boolean |
true , if the section has a header of the specified type; otherwise, false.
|
When a new header is created using the Section.BeginUpdateHeader method without arguments, it is the header of the HeaderFooterType.Primary type which is the same for all pages, unless the Section.DifferentFirstPage or the Document.DifferentOddAndEvenPages properties are set to true. So in this situation, you can use the HasHeader method to check for the HeaderFooterType.Primary header type.
using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
Document document = wordProcessor.Document;
Section firstSection = document.Sections[0];
// Check whether the document already has a header (the same header for all pages).
if (!firstSection.HasHeader(HeaderFooterType.Primary))
{
//If not, create an empty header.
SubDocument headerDocument = firstSection.BeginUpdateHeader();
headerDocument.Paragraphs.Append();
firstSection.EndUpdateHeader(headerDocument);
}
}
Using wordProcessor As New RichEditDocumentServer()
Dim document As Document = wordProcessor.Document
Dim firstSection As Section = document.Sections(0)
' Check whether the document already has a header (the same header for all pages).
If Not firstSection.HasHeader(HeaderFooterType.Primary) Then
'If not, create an empty header.
Dim headerDocument As SubDocument = firstSection.BeginUpdateHeader()
headerDocument.Paragraphs.Append()
firstSection.EndUpdateHeader(headerDocument)
End If
End Using
The following code snippets (auto-collected from DevExpress Examples) contain references to the HasHeader(HeaderFooterType) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/WatermarkActions.cs#L19
{
if (!section.HasHeader(HeaderFooterType.Primary))
{
word-document-api-examples/CS/CodeExamples/HeaderAndFooterActions.cs#L22
// Check whether the document already has a header (the same header for all pages).
if (!firstSection.HasHeader(HeaderFooterType.Primary))
{
word-processing-merge-documents-with-different-headers-and-footers/CS/Helpers/SectionsMerger.cs#L27
private static void AppendHeader(Section sourceSection, Section targetSection, HeaderFooterType headerFooterType) {
if (!sourceSection.HasHeader(headerFooterType)) return;
winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/HeaderAndFooter.cs#L18
// Check whether the document already has a header (the same header for all pages).
if (!firstSection.HasHeader(HeaderFooterType.Primary))
{
winforms-richedit-iterate-through-all-sub-documents/CS/SubDocumentHelper.cs#L27
{
if (section.HasHeader(headerFooterType))
{
word-document-api-examples/VB/CodeExamples/HeaderAndFooterActions.vb#L20
' Check whether the document already has a header (the same header for all pages).
If Not firstSection.HasHeader(DevExpress.XtraRichEdit.API.Native.HeaderFooterType.Primary) Then
' Create a header.
word-processing-merge-documents-with-different-headers-and-footers/VB/Helpers/SectionsMerger.vb#L27
Private Shared Sub AppendHeader(ByVal sourceSection As Section, ByVal targetSection As Section, ByVal headerFooterType As HeaderFooterType)
If Not sourceSection.HasHeader(headerFooterType) Then Return
Dim source As SubDocument = sourceSection.BeginUpdateHeader(headerFooterType)
winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/HeaderAndFooter.vb#L17
' Check whether the document already has a header (the same header for all pages).
If Not firstSection.HasHeader(DevExpress.XtraRichEdit.API.Native.HeaderFooterType.Primary) Then
Dim headerDocument As DevExpress.XtraRichEdit.API.Native.SubDocument = firstSection.BeginUpdateHeader()
winforms-richedit-iterate-through-all-sub-documents/VB/SubDocumentHelper.vb#L23
Private Sub ProcessSection(ByVal section As Section, ByVal headerFooterType As HeaderFooterType, ByVal subDocumentProcessor As SubDocumentDelegate)
If section.HasHeader(headerFooterType) Then
Dim header As SubDocument = section.BeginUpdateHeader(headerFooterType)
wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/HeaderAndFooterActions.vb#L17
' Check whether the document already has a header (the same header for all pages).
If firstSection.HasHeader(HeaderFooterType.Primary) Then
Dim headerDocument As SubDocument = firstSection.BeginUpdateHeader()
See Also