I have this battleship program where i am trying to access a function in another form. This function is used to change the buttons on the game board to either enabled or disabled, depending on who’s turn it is. Changing the buttons to enabled and disabled is not my problem. My problem is accessing the function to do it in the other form. I would post code, but it is lengthy and spread between three forms.
Appreciate any help!
Thanks in advance!
Luke
It depends on your code architecture:
Kind of rough one: If you just have several forms
Form _form1, Form2 _form2, you can create kind of relationship between them, by, just an example pseudocode:More nice one: is declare shared between all your forms event Dispatcher. So when
Form1wants to notify somethign toForm2it calls Dispatchers relative method, which takes care to call right method onForm2There could be a lot of other solutions more or less nicer, but it strongly depends on your app architecture. Here I just put down a couple of choices you could have.
Hope this helps.
Regards.