TablePattern.TablePatternInformation.GetRowHeaders 메서드

정의

테이블의 모든 행 머리글을 나타내는 AutomationElement 컬렉션을 검색합니다.

public:
 cli::array <System::Windows::Automation::AutomationElement ^> ^ GetRowHeaders();
public System.Windows.Automation.AutomationElement[] GetRowHeaders ();
member this.GetRowHeaders : unit -> System.Windows.Automation.AutomationElement[]
Public Function GetRowHeaders () As AutomationElement()

반환

AutomationElement[]

AutomationElement의 컬렉션입니다. 기본값은 빈 배열입니다.

예제

다음 예제에서는 특정 테이블 항목에 대 한 행 또는 열 헤더를 검색 합니다.

이 예제에서는 간의 관계를 위해는 RowOrColumnMajor 속성 행 및 열 머리글 항목에 대해서는 설명 합니다. 그러나 테이블 행 및 열 머리글에 관계 없이 있습니다를 RowOrColumnMajor 테이블의 속성입니다.

///--------------------------------------------------------------------
/// <summary>
/// Obtains a table items primary row or column header.
/// </summary>
/// <param name="tableItem">
/// The table item of interest.
/// </param>
/// <returns>
/// The table item header.
/// </returns>
///--------------------------------------------------------------------
private AutomationElement GetTableItemHeader(TableItemPattern tableItem)
{
    if (tableItem == null)
    {
        throw new ArgumentException("Target element cannot be null.");
    }

    TablePattern tablePattern = GetTablePattern(tableItem.Current.ContainingGrid);

    if (tablePattern == null)
    {
        return null;
    }

    AutomationElement[] tableHeaders = 
        GetPrimaryHeaders(tablePattern);

    if (tableHeaders == null)
    {
        // Indeterminate headers.
        return null;
    }

    if (tablePattern.Current.RowOrColumnMajor == RowOrColumnMajor.ColumnMajor)
    {
        return tableHeaders[tableItem.Current.Column];
    }

    if (tablePattern.Current.RowOrColumnMajor == RowOrColumnMajor.RowMajor)
    {
        return tableHeaders[tableItem.Current.Row];
    }

    return null;
}

///--------------------------------------------------------------------
/// <summary>
/// Obtains an array of table headers.
/// </summary>
/// <param name="tablePattern">
/// The TablePattern object of interest.
/// </param>
/// <returns>
/// The table row or column primary headers.
/// </returns>
///--------------------------------------------------------------------
private AutomationElement[] GetPrimaryHeaders(
    TablePattern tablePattern)
{
    if (tablePattern.Current.RowOrColumnMajor == 
        RowOrColumnMajor.RowMajor)
    {
        return tablePattern.Current.GetRowHeaders();
    }

    if (tablePattern.Current.RowOrColumnMajor == 
        RowOrColumnMajor.ColumnMajor)
    {
        return tablePattern.Current.GetColumnHeaders();
    }

    return null;
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains a table items primary row or column header.
''' </summary>
''' <param name="tableItem">
''' The table item of interest.
''' </param>
''' <returns>
''' The table item header.
''' </returns>
'''--------------------------------------------------------------------
Private Function GetTableItemHeader( _
ByVal tableItem As TableItemPattern) As AutomationElement
    If tableItem Is Nothing Then
        Throw New ArgumentException("Target element cannot be null.")
    End If

    Dim tablePattern As TablePattern = _
    GetTablePattern(tableItem.Current.ContainingGrid)

    If tablePattern Is Nothing Then
        Return Nothing
    End If

    Dim tableHeaders As AutomationElement() = _
    GetPrimaryHeaders(tablePattern)

    If tableHeaders Is Nothing Then
        ' Indeterminate headers.
        Return Nothing
    End If

    If tablePattern.Current.RowOrColumnMajor = _
    RowOrColumnMajor.ColumnMajor Then
        Return tableHeaders(tableItem.Current.Column)
    End If

    If tablePattern.Current.RowOrColumnMajor = _
    RowOrColumnMajor.RowMajor Then
        Return tableHeaders(tableItem.Current.Row)
    End If

    Return Nothing

End Function 'GetTableItemHeader    

'''--------------------------------------------------------------------
''' <summary>
''' Obtains an array of table headers.
''' </summary>
''' <param name="tablePattern">
''' The TablePattern object of interest.
''' </param>
''' <returns>
''' The table primary row or column headers.
''' </returns>
'''--------------------------------------------------------------------
Private Overloads Function GetPrimaryHeaders( _
ByVal tablePattern As TablePattern) As AutomationElement()
    If tablePattern.Current.RowOrColumnMajor = _
    RowOrColumnMajor.RowMajor Then
        Return tablePattern.Current.GetRowHeaders()
    End If

    If tablePattern.Current.RowOrColumnMajor = _
    RowOrColumnMajor.ColumnMajor Then
        Return tablePattern.Current.GetColumnHeaders()
    End If

    Return Nothing

End Function 'GetPrimaryHeaders

적용 대상

추가 정보