Share via


CursorButtons.GetEnumerator Method

CursorButtons.GetEnumerator Method

Returns an object that implements the System.Collections.IEnumerator Leave Site interface and that can iterate through the CursorButton objects within the CursorButtons collection.

Definition

Visual Basic .NET Public Function GetEnumerator() As CursorButtonsEnumerator
C# public CursorButtonsEnumerator GetEnumerator();
Managed C++ public: CursorButtonsEnumerator* GetEnumerator();

Return Value

Microsoft.Ink.CursorButtons.CursorButtonsEnumerator. Returns an object that implements the IEnumerator Leave Site interface and that can iterate through the CursorButton objects within the CursorButtons collection.

Examples

[C#]

These C# examples show two ways to iterate over the CursorButtons collection and get the name for each CursorButton object in the Cursor object, theCursor. The CursorButtons collection is returned by the Cursor.Buttons property.

This C# example gets the IEnumerator Leave Site for the CursorButtons collection.

ArrayList names = new ArrayList();
// Version using GetEnumerator()
IEnumerator ienum = theCursor.Buttons.GetEnumerator();
while (ienum.MoveNext())
{
    CursorButton theButton = (CursorButton) ienum.Current;
    names.Add(theButton.Name)
}

This C# example uses the foreach statement, which calls the GetEnumerator method in internal code that the compiler generates to support the statement.

ArrayList names = new ArrayList();
// Version using foreach
foreach (CursorButton theButton in theCursor.Buttons)
{
    names.Add(theButton.Name);
}

[VB.NET]

These Microsoft® Visual Basic® .NET examples show two ways to iterate over the CursorButtons collection and get the name for each CursorButton object in the Cursor object, theCursor. The CursorButtons collection is returned by the Cursor.Buttons property.

This Visual Basic .NET example gets the IEnumerator Leave Site for the CursorButtons collection.

'Version using GetEnumerator()
Dim names As New ArrayList()
Dim theButton as CursorButton
Dim ienum as IEnumerator = theCursor.Buttons.GetEnumerator()
While (ienum.MoveNext())
    theButton = ienum.Current
    names.Add(theButton.Name)
End While

This Visual Basic .NET example uses the For Each statement, which calls the GetEnumerator method in internal code that the compiler generates to support the statement.

'Version using For Each
Dim names As New ArrayList()
Dim theButton as CursorButton

For Each theButton In theCursor.Buttons
    names.Add(theButton.Name)
Next

See Also