You can either enumerate (or iterate) over the Controls collection property which already contains your controls that are displayed on a form, or add specific control references (as Mike mentioned, not "pointers"). If you only want to deal with controls of a specific type, for instance, then you could do something like this:
foreach (Control c in Controls)
{
if (c is Button)
{
Button b = (Button)c;
b.Text = "Click me!";
}
}
When you enumerate a collection, list, or any other IEnumerable implementation, do not change the underlying enumerable otherwise an exception will be thrown. If you must change the collection or list or whatever, then iterate (the ol' for loop) over the collection or list instead and update your current index accordingly. There have been times when I wanted to keep a separate list or array (which is a static list, BTW) of certain controls in my form so I could deal with them in a loop as well. You could easily do something like this:
Control[] controls = new Control[] {
this.textBox1,
this.textBox2,
thix.button5
};
// Later...
foreach (Control c in controls)
// ...
// -- OR --
for (int i=0; i<controls.Length; i++)
// ...
Microsoft MVP, Visual C# My Articles