TablePattern.TablePatternInformation.GetRowHeaders 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
检索一个表示表格中所有行标题的 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 的集合。 默认为空数组。
示例
在以下示例中,为特定表项检索行或列标题。
本示例演示了属性与行标题项和列标题项之间的关系 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