共用方式為


AutomationElementCollection.Item[Int32] 屬性

定義

取得指定索引處的 AutomationElement

public:
 property System::Windows::Automation::AutomationElement ^ default[int] { System::Windows::Automation::AutomationElement ^ get(int index); };
public System.Windows.Automation.AutomationElement this[int index] { get; }
member this.Item(int) : System.Windows.Automation.AutomationElement
Default Public ReadOnly Property Item(index As Integer) As AutomationElement

參數

index
Int32

集合中項目之以零起始的索引。

屬性值

AutomationElement

指定之索引處的 AutomationElement

例外狀況

index 指定為負整數,或index 大於或等於 Count

範例

在下列範例中,會從 擷取第一個專案 AutomationElementCollection

// desktopChildren is a collection of AutomationElement objects.
AutomationElement firstWindow;
try
{
    firstWindow = desktopChildren[0];
}
catch (IndexOutOfRangeException)
{
    Console.WriteLine("No AutomationElement at that index.");
}
' desktopChildren is a collection of AutomationElement objects.
Dim firstWindow As AutomationElement
Try
    firstWindow = desktopChildren(0)
Catch ex As IndexOutOfRangeException
    Console.WriteLine("No AutomationElement at that index.")
End Try

適用於