次の方法で共有


TablePattern.TablePatternInformation.RowOrColumnMajor プロパティ

定義

テーブルの主要な移動方向 (ColumnMajorRowMajorIndeterminate) を取得します。

public:
 property System::Windows::Automation::RowOrColumnMajor RowOrColumnMajor { System::Windows::Automation::RowOrColumnMajor get(); };
public System.Windows.Automation.RowOrColumnMajor RowOrColumnMajor { get; }
member this.RowOrColumnMajor : System.Windows.Automation.RowOrColumnMajor
Public ReadOnly Property RowOrColumnMajor As RowOrColumnMajor

プロパティ値

主要な移動方向。 既定値は、Indeterminate です。

次の例では、特定のテーブル項目の行ヘッダーまたは列ヘッダーが取得されます。

この例では、 プロパティと行ヘッダー項目と列ヘッダー項目の間 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

適用対象

こちらもご覧ください