I’m trying to change an Object’s properties from another class, like so.
abilities.cs (class)
public static void hideAllButtons()
{
frmFight fight = new frmFight();
fight.btnAbility1.Visible = false;
fight.btnAbility2.Visible = false;
fight.btnAbility3.Visible = false;
fight.btnAbility4.Visible = false;
fight.btnAbility5.Visible = false;
fight.btnAbility6.Visible = false;
vars.buttonsVisible = false;
}
I’m trying to use the method from the previous class to change the object’s properties in the following Form;
frmFight.cs (form)
private void btnAbility1_Click(object sender, EventArgs e)
{
abilities.hideAllButtons();
btnAbilities.Enabled = false;
}
I’ve tried everything in my knowledge and understanding, and a lot of looking up on the internet. I’ve tried making the objects static, public, creating the object within the class. But nothing works. Usually I get StackOverFlow errors.
I’m pretty new to OOP, too, but I’m not an idiot so don’t think to go too ‘lightly’ on me with a possible fix, or cause, of my problem – if you understand, that is.
Method
hideAllButtonsis static so should have a Form argument.and call this method in click handler,