if you placed the buttons on a form via designer view or even programmatically created and added it into the Controls collection, you can access them via the Controls collection. Or if you know the names of the buttons and it was in the format of:
ButtonNumber
then you can still do that too.
foreach(Control curControl in this.Controls)
{
if (currentControl.GetType == typeOf(Button))
{
//current control IS a button. Now modify its properties like so:
currentControl.Visible = false;
}
}
you could do it this way too:
for (int counter = 1; counter <= 12; counter++)
{
Button theButton = this.Controls["Button" + counter.ToString()];
if (theButton != null)
{
theButton.Visible = false;
}
}
is this something you are after
|