I know this question has been asked before or similar questions asked but none of the solutions has yet fixed my problem.
I have a winform that has a button named hitButton
. All I need to do is to disable this button from another class (i.e. not the form class).
My form class is:
public partial class BlackJackTable : Form
{
}
My separate class is:
class GameWon
{
}
I have tried exposing a public method in BlackJackTable
like this:
public void DisableButtons()
{
hitButton.Enabled = false;
}
and accessing from GameWon
constructor (it doesn't seem to matter where in the class I access it from though) like this:
public BlackJackTable blackJackTable = new BlackJackTable();
public GameWon()
{
blackJackTable.DisableButtons();
}
I have tried using a variable in GameWon
:
public Button hit;
and assigning from blackJackTable:
GameWon gameWon = new GameWon();
public void Assign()
{
gameWon.hit = this.hitButton; // or just = hitButton;
}
and disabling from GameWon
:
hit.Enabled = false;
I have tried a couple of other things but none of them work. I'm guessing I'm missing something obvious as none of the methods I've tried have worked.
Any thoughts appreciated!
Update
I have managed to do the latter method with textboxes and pictureboxes, what's the difference with a button?
No comments:
Post a Comment