public Guna2TileButton [] topNav =
{
//this.report,
};
here there are 10 GUNA tile buttons and I want to collect them in an array to help me alter there property active button styling.. I don't want to write 10 if else statement for every button.. array will help me simplify that.. can any one help me
CodePudding user response:
If you already have the class instances created, you can simply include those instances within the the array initialiser:
public Guna2TileButton[] topNav = { instance1, instance2 };
Or you can create the objects directly:
public Guna2TileButton[] topNav =
{
new Guna2TileButton() { /* Set properties here */ },
new Guna2TileButton() { /* Set properties here */ },
};
CodePudding user response:
you can catch all of them with this syntax:
Guna2TileButton = this.Controls.OfType<Button>().ToArray();
or
List<Button> buttons = new List<Button> { firstButton, secondButton };