共用方式為


TableItemPattern.ColumnHeaderItemsProperty 欄位

定義

識別用來擷取與資料表項目或儲存格相關聯之所有資料行標頭的屬性。

public: static initonly System::Windows::Automation::AutomationProperty ^ ColumnHeaderItemsProperty;
public static readonly System.Windows.Automation.AutomationProperty ColumnHeaderItemsProperty;
 staticval mutable ColumnHeaderItemsProperty : System.Windows.Automation.AutomationProperty
Public Shared ReadOnly ColumnHeaderItemsProperty As AutomationProperty 

欄位值

AutomationProperty

範例

在下列範例中,會擷取代表資料表之主要資料列或資料行標頭專案的自動化專案物件陣列。

為了本範例的目的,會示範 屬性與資料列和資料行標頭專案之間的 RowOrColumnMajor 關聯性。 不過,不論資料表的 屬性為何 RowOrColumnMajor ,資料表都可以有資料列和資料行標頭。

///--------------------------------------------------------------------
/// <summary>
/// Obtains an array of primary table headers.
/// </summary>
/// <param name="targetControl">
/// The target control of interest.
/// </param>
/// <param name="roworcolumnMajor">
/// The RowOrColumnMajor specifier.
/// </param>
/// <returns>
/// An AutomationElement array object.
/// </returns>
///--------------------------------------------------------------------
private Object GetPrimaryHeaders(
    AutomationElement targetControl, RowOrColumnMajor roworcolumnMajor)
{
    if (targetControl == null)
    {
        throw new ArgumentException("Target element cannot be null.");
    }

    try
    {
        if (roworcolumnMajor ==
            RowOrColumnMajor.RowMajor)
        {
            return targetControl.GetCurrentPropertyValue(
                TableItemPattern.RowHeaderItemsProperty);
        }

        if (roworcolumnMajor ==
            RowOrColumnMajor.ColumnMajor)
        {
            return targetControl.GetCurrentPropertyValue(
                TableItemPattern.ColumnHeaderItemsProperty);
        }
    }
    catch (InvalidOperationException)
    {
        // TableItemPattern not supported.
        // TO DO: error processing.
    }

    return null;
}
    '''--------------------------------------------------------------------
    ''' <summary>
    ''' Obtains an array of primary table headers.
    ''' </summary>
    ''' <param name="targetControl">
    ''' The target control of interest.
    ''' </param>
    ''' <param name="roworcolumnMajor">
    ''' The RowOrColumnMajor specifier.
    ''' </param>
    ''' <returns>
    ''' An AutomationElement array object.
    ''' </returns>
    '''--------------------------------------------------------------------
    Private Function GetPrimaryHeaders( _
    ByVal targetControl As AutomationElement, _
    ByVal roworcolumnMajor As RowOrColumnMajor) As [Object]
        If targetControl Is Nothing Then
            Throw New ArgumentException("Target element cannot be null.")
        End If

        Try
            If roworcolumnMajor = roworcolumnMajor.RowMajor Then
                Return targetControl.GetCurrentPropertyValue( _
                TableItemPattern.RowHeaderItemsProperty)
            End If

            If roworcolumnMajor = roworcolumnMajor.ColumnMajor Then
                Return targetControl.GetCurrentPropertyValue( _
                TableItemPattern.ColumnHeaderItemsProperty)
            End If
        Catch
        End Try
        ' TableItemPattern not supported.
        ' TO DO: error processing.

        Return Nothing

    End Function 'GetPrimaryHeaders
End Class

備註

消費者介面自動化用戶端應用程式會使用此識別碼。 消費者介面自動化提供者應該使用 中的 TableItemPatternIdentifiers 對等欄位。

此屬性不存在於 中 TableItemPattern.TableItemPatternInformation ,而且必須使用 或 GetCachedPropertyValueGetCurrentPropertyValue 擷取。

適用於

另請參閱