共用方式為


Tablets.GetEnumerator 方法

傳回物件,這個物件會實作 System.Collections.IEnumerator (英文) 介面,並且能逐一查看 Tablets 集合內的 Tablet 物件。

命名空間:  Microsoft.Ink
組件:  Microsoft.Ink (在 Microsoft.Ink.dll 中)

語法

'宣告
Public Function GetEnumerator As Tablets..::.TabletsEnumerator
'用途
Dim instance As Tablets
Dim returnValue As Tablets..::.TabletsEnumerator

returnValue = instance.GetEnumerator()
public Tablets..::.TabletsEnumerator GetEnumerator()
public:
Tablets..::.TabletsEnumerator^ GetEnumerator()
public Tablets..::.TabletsEnumerator GetEnumerator()
public function GetEnumerator() : Tablets..::.TabletsEnumerator

傳回值

型別:Microsoft.Ink.Tablets.TabletsEnumerator
傳回物件,這個物件會實作 IEnumerator (英文) 介面,並且能逐一查看 Tablets 集合內的 Tablet 物件。

範例

在這些範例中,會示範兩種反覆查看 Tablets 集合 allTablets 的方式,並且將附加至系統的每個手寫板裝置名稱填入 ListBox (英文) 物件 listBoxTablets。

這個範例會取得 Tablets 集合的 IEnumerator (英文)。

' Calling the constructor automatically fills the 
' Tablets collection with the available Tablet objects.
Dim allTablets As Tablets = New Tablets()

' clear the list box
Me.listBoxTablets.Items.Clear()

' populate the list box with the name of each tablet
' version using GetEnumerator()
Dim theTabletsEnumerator As IEnumerator = allTablets.GetEnumerator()
While (theTabletsEnumerator.MoveNext())
    Dim T As Tablet = theTabletsEnumerator.Current
    Me.listBoxTablets.Items.Add(T.Name)
End While
// Calling the constructor automatically fills the 
// Tablets collection with the available Tablet objects.
Tablets allTablets = new Tablets();

// clear the list box
this.listBoxTablets.Items.Clear();

// populate the list box with the name of each tablet
// version using GetEnumerator()
IEnumerator theTabletsEnumerator = allTablets.GetEnumerator();
while (theTabletsEnumerator.MoveNext())
{
    Tablet T = (Tablet)theTabletsEnumerator.Current;
    this.listBoxTablets.Items.Add(T.Name);
}

這個範例會使用 foreach 陳述式,該陳述式會在內部程式碼中呼叫編譯器 (Compiler) 所產生用來支援該陳述式的 GetEnumerator 方法。

' Calling the constructor automatically fills the 
' Tablets collection with the available Tablet objects.
Dim allTablets As Tablets = New Tablets()

' clear the list box
Me.listBoxTablets.Items.Clear()

' populate the list box with the name of each tablet
' version using For Each
For Each T As Tablet In allTablets
    Me.listBoxTablets.Items.Add(T.Name)
Next
// Calling the constructor automatically fills the 
// Tablets collection with the available Tablet objects.
Tablets allTablets = new Tablets();

// clear the list box
this.listBoxTablets.Items.Clear();

// populate the list box with the name of each tablet
// version using foreach
foreach (Tablet T in allTablets)
{
    this.listBoxTablets.Items.Add(T.Name);
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求

版本資訊

.NET Framework

支援版本:3.0

請參閱

參考

Tablets 類別

Tablets 成員

Microsoft.Ink 命名空間

Tablet