TableItemPattern.TableItemPatternInformation.Column プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
テーブルのセルまたは項目を格納している列の序数を取得します。
public:
property int Column { int get(); };
public int Column { get; }
member this.Column : int
Public ReadOnly Property Column As Integer
プロパティ値
テーブルのセルまたは項目を格納する列を表す、0 から始まる序数。
例
次の例では、テーブル コンテナー内の AutomationFocusChangedEvent テーブル項目のトラバーサルを追跡するリスナーが宣言されています。 項目のプロパティは、フォーカスが変更されたイベントごとに記録されます。
///--------------------------------------------------------------------
/// <summary>
/// Set up table item event listeners.
/// </summary>
/// <remarks>
/// The event listener is essentially a focus change listener.
/// Since this is a global desktop listener, a filter would be required
/// to ignore focus change events outside the table.
/// </remarks>
///--------------------------------------------------------------------
private void SetTableItemEventListeners()
{
AutomationFocusChangedEventHandler tableItemFocusChangedListener =
new AutomationFocusChangedEventHandler(OnTableItemFocusChange);
Automation.AddAutomationFocusChangedEventHandler(
tableItemFocusChangedListener);
}
'''--------------------------------------------------------------------
''' <summary>
''' Set up table item event listeners.
''' </summary>
''' <remarks>
''' The event listener is essentially a focus change listener.
''' Since this is a global desktop listener, a filter would be required
''' to ignore focus change events outside the table.
''' </remarks>
'''--------------------------------------------------------------------
Private Sub SetTableItemEventListeners( _
ByVal targetControl As AutomationElement)
Dim tableItemFocusChangedListener As AutomationFocusChangedEventHandler = _
AddressOf OnTableItemFocusChange
Automation.AddAutomationFocusChangedEventHandler( _
tableItemFocusChangedListener)
End Sub
///--------------------------------------------------------------------
/// <summary>
/// Event handler for table item focus change.
/// Can be used to track traversal of individual table items
/// within a table.
/// </summary>
/// <param name="src">Object that raised the event.</param>
/// <param name="e">Event arguments.</param>
///--------------------------------------------------------------------
private void OnTableItemFocusChange(
object src, AutomationFocusChangedEventArgs e)
{
// Make sure the element still exists. Elements such as tooltips
// can disappear before the event is processed.
AutomationElement sourceElement;
try
{
sourceElement = src as AutomationElement;
}
catch (ElementNotAvailableException)
{
return;
}
// Get a TableItemPattern from the source of the event.
TableItemPattern tableItemPattern =
GetTableItemPattern(sourceElement);
if (tableItemPattern == null)
{
return;
}
// Get a TablePattern from the container of the current element.
TablePattern tablePattern =
GetTablePattern(tableItemPattern.Current.ContainingGrid);
if (tablePattern == null)
{
return;
}
AutomationElement tableItem = null;
try
{
tableItem = tablePattern.GetItem(
tableItemPattern.Current.Row,
tableItemPattern.Current.Column);
}
catch (ArgumentOutOfRangeException)
{
// If the requested row coordinate is larger than the RowCount
// or the column coordinate is larger than the ColumnCount.
// -- OR --
// If either of the requested row or column coordinates
// is less than zero.
// TO DO: error handling.
}
// Further event processing can be done at this point.
// For the purposes of this sample we can just record item properties.
string controlType =
tableItem.Current.ControlType.LocalizedControlType;
AutomationElement[] columnHeaders =
tableItemPattern.Current.GetColumnHeaderItems();
AutomationElement[] rowHeaders =
tableItemPattern.Current.GetRowHeaderItems();
int itemRow = tableItemPattern.Current.Row;
int itemColumn = tableItemPattern.Current.Column;
int itemRowSpan = tableItemPattern.Current.RowSpan;
int itemColumnSpan = tableItemPattern.Current.ColumnSpan;
}
///--------------------------------------------------------------------
/// <summary>
/// Handles the application shutdown.
/// </summary>
/// <param name="args">Event arguments.</param>
///--------------------------------------------------------------------
protected override void OnExit(System.Windows.ExitEventArgs args)
{
Automation.RemoveAllEventHandlers();
base.OnExit(args);
}
'''--------------------------------------------------------------------
''' <summary>
''' Event handler for table item focus change.
''' Can be used to track traversal of individual table items
''' within a table.
''' </summary>
''' <param name="src">Object that raised the event.</param>
''' <param name="e">Event arguments.</param>
'''--------------------------------------------------------------------
Private Sub OnTableItemFocusChange( _
ByVal src As Object, ByVal e As AutomationFocusChangedEventArgs)
' Make sure the element still exists. Elements such as tooltips
' can disappear before the event is processed.
Dim sourceElement As AutomationElement
Try
sourceElement = DirectCast(src, AutomationElement)
Catch exc As ElementNotAvailableException
Return
End Try
' Get a TableItemPattern from the source of the event.
Dim tableItemPattern As TableItemPattern = _
GetTableItemPattern(sourceElement)
If tableItemPattern Is Nothing Then
Return
End If
' Get a TablePattern from the container of the current element.
Dim tablePattern As TablePattern = _
GetTablePattern(tableItemPattern.Current.ContainingGrid)
If tablePattern Is Nothing Then
Return
End If
Dim tableItem As AutomationElement = Nothing
Try
tableItem = tablePattern.GetItem( _
tableItemPattern.Current.Row, tableItemPattern.Current.Column)
Catch exc As ArgumentOutOfRangeException
' If the requested row coordinate is larger than the RowCount
' or the column coordinate is larger than the ColumnCount.
' -- OR --
' If either of the requested row or column coordinates
' is less than zero.
' TO DO: error handling.
End Try
' Further event processing can be done at this point.
' For the purposes of this sample we can just record item properties.
Dim controlType As String = _
tableItem.Current.ControlType.LocalizedControlType
Dim columnHeaders As AutomationElement() = _
tableItemPattern.Current.GetColumnHeaderItems()
Dim rowHeaders As AutomationElement() = _
tableItemPattern.Current.GetRowHeaderItems()
Dim itemRow As Integer = tableItemPattern.Current.Row
Dim itemColumn As Integer = tableItemPattern.Current.Column
Dim itemRowSpan As Integer = tableItemPattern.Current.RowSpan
Dim itemColumnSpan As Integer = tableItemPattern.Current.ColumnSpan
End Sub
'''--------------------------------------------------------------------
''' <summary>
''' Handles the application shutdown.
''' </summary>
''' <param name="args">Event arguments.</param>
'''--------------------------------------------------------------------
Protected Overrides Sub OnExit(ByVal args As System.Windows.ExitEventArgs)
Automation.RemoveAllEventHandlers()
MyBase.OnExit(args)
End Sub
適用対象
こちらもご覧ください
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET