Freigeben über


NamedRange.ListHeaderRows Property

Definition

Gets the number of header rows for the NamedRange control.

public:
 property int ListHeaderRows { int get(); };
public int ListHeaderRows { get; }
member this.ListHeaderRows : int
Public ReadOnly Property ListHeaderRows As Integer

Property Value

The number of header rows for the NamedRange control.

Examples

The following code example creates a NamedRange and then displays a message that shows the number of header rows in the NamedRange.

This example is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange getHeadersRange;
private void GetNumberOfHeaderRows()
{
    this.Range["A1"].Value2 = "Row 1";
    this.Range["B1"].Value2 = "Row 2";
    this.Range["C1"].Value2 = "Row 3";

    this.Range["A2", "A5"].Value2 = 10;
    this.Range["B2", "B5"].Value2 = 20;
    this.Range["C2", "C5"].Value2 = 30;

    getHeadersRange = this.Controls.AddNamedRange(
        this.Range["A1", "C5"], "getHeadersRange");

    MessageBox.Show("The NamedRange contains " +
        getHeadersRange.ListHeaderRows + " header row.");
}
Private getHeadersRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub GetNumberOfHeaderRows()
    Me.Range("A1").Value2 = "Row 1"
    Me.Range("B1").Value2 = "Row 2"
    Me.Range("C1").Value2 = "Row 3"

    Me.Range("A2", "A5").Value2 = 10
    Me.Range("B2", "B5").Value2 = 20
    Me.Range("C2", "C5").Value2 = 30

    getHeadersRange = Me.Controls.AddNamedRange( _
        Me.Range("A1", "C5"), "getHeadersRange")

    MessageBox.Show("The NamedRange contains " & _
        getHeadersRange.ListHeaderRows & " header row.")
End Sub

Applies to