I have 20 iconbuttons in my form. when clickevent is performed i want to change buttons(backcolor,forecolor,Iconcolor) and remaining buttons should revert to it's default color.
public void btn1()
{
foreach (Control c in this.Controls)
{
if (c is Button)
{
(c as Button).ForeColor = Color.White;
(c as Button).BackColor = Color.FromArgb(46, 51, 73);
}
}
}

You can make each button listen to the same Click event and do some conditional logic to achieve this.
First, make each of your buttons reference the same click event. You can do this from the Form Designer by clicking the button and in the Properties window, click the lightening bolt icon (the events icon) and change the Click event to be the method you wish:
Then, make your event method do something like this:
This gets the type of the
sender(the clicked button in this case), and sets theBackColorproperty of it. Then, theforeachloop loops over all of the controls in the form, checks if the current item in the list is a button and is not the button that was clicked, it will change theBackColorproperty. Obviously, you can change other properties of both the clicked button, and the other buttons in theforeach.If done properly, this is how it should behave: