I'm trying to make a function with a parameter so whenever I call it, it will change the button's back color but my code doesn't work, any ideas
Button button = new Button();
private void Change(object sender)
{
if (button.Visible == true)
{
button.BackColor = Color.Red;
}
}
private void hr1_left2_btn_MouseEnter(object sender, EventArgs e)
{
Change(hr1_left2_btn);
}
CodePudding user response:
Perhaps like this? I've changed the Sender Arg type of the Change function to ref a button object.
private void Change(Button sender) {
if (sender.Visible)
sender.BackColor = Color.Red;
}
private void hr1_left2_btn_MouseEnter(object sender, EventArgs e) {
Change(hr1_left2_btn);
}