Make it a Click
event handler, attach it to each button, and use the sender
parameter as the button to change.
void button_Click(Object sender, EventArgs e)
{
var button = sender as Button;
if(button != null)
{
button.Text = "X";
button.ForeColor = System.Drawing.Color.Red;
}
}
solved How to pass button object to function