'How to change properties just one button

Hey, I have multiple buttons.I want to reduce the code so that I can set the properties of a button, but only the one I click on will change.So that I don't click on button_1 and change all the others

 public static void SetProp()
        {
            for (int i = 0; i < buttons.Count; i++)
            {
                buttons[i].Image = Properties.Resources.test;
                buttons[i].Width = buttons[i].Image.Width;
                buttons[i].Height = buttons[i].Image.Height;
                buttons[i].ImageAlign = ContentAlignment.MiddleCenter;
                buttons[i].Text = null;
                GraphicsPath gp = new GraphicsPath();
                gp.AddEllipse(0, 0, buttons[i].Width, buttons[i].Height);
                buttons[i].Region = new Region(gp);
                gp.Dispose();
            }
        }
   private void button1_Click(object sender, EventArgs e)
        {
            SetProp();
          

        }


Solution 1:[1]

 public static void SetProp(Button button)
        {
            for (int i = 0; i < buttons.Count; i++)
            {
                button.Image = Properties.Resources.test;
                button.Width = buttons[i].Image.Width;
                button.Height = buttons[i].Image.Height;
                button.ImageAlign = ContentAlignment.MiddleCenter;
                button.Text = null;
                GraphicsPath gp = new GraphicsPath();
                gp.AddEllipse(0, 0, button.Width, button.Height);
                button.Region = new Region(gp);
                gp.Dispose();
            }
        }
 private void button1_Click(object sender, EventArgs e)
        {
            SetProp(sender as Button);
           
          
        }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Morine