ControlCollection.GetEnumerator Method (2007 System)
Returns an enumerator that enables you to iterate through the ControlCollection instance.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
Syntax
'Declaration
Public Function GetEnumerator As IEnumerator
'Usage
Dim instance As ControlCollection
Dim returnValue As IEnumerator
returnValue = instance.GetEnumerator()
public IEnumerator GetEnumerator()
public:
IEnumerator^ GetEnumerator()
public function GetEnumerator() : IEnumerator
Return Value
Type: System.Collections.IEnumerator
An IEnumerator for the ControlCollection instance.
Examples
The following code example adds a Button control to the start of the document, and then uses GetEnumerator to display each control's name in a message box.
Private Sub WordControlGetEnumerator()
Me.Paragraphs(1).Range.InsertParagraphBefore()
Dim Button1 As Microsoft.Office.Tools.Word.Controls.Button _
= Me.Controls.AddButton(0, 0, 56.25F, 17.25F, "Button1")
Button1.Text = "OK"
Dim en As System.Collections.IEnumerator = Me.Controls. _
GetEnumerator()
While en.MoveNext()
MessageBox.Show(en.Current.ToString())
End While
End Sub
private void WordControlGetEnumerator()
{
this.Paragraphs[1].Range.InsertParagraphBefore();
Microsoft.Office.Tools.Word.Controls.Button button1 =
this.Controls.AddButton(0, 0, 56.25F, 17.25F,
"button1");
button1.Text = "OK";
System.Collections.IEnumerator en = this.Controls.GetEnumerator();
while (en.MoveNext())
{
MessageBox.Show(en.Current.ToString());
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.