I have Class2, Form1 and Control1.
class Class2
{
public int number = 0;
public string name = "X";
public event EventHandler DataAvailable;
public void OnDataAvailable(EventArgs e)
{
if (DataAvailable != null) DataAvailable(this, e);
}
}
1- When I press a button in Control1, i update 'number' in Class2.
2- When I press a button in Form1, i update 'number' in Class2.
3- The event from Class2 is fired every time when a button is pressed from either controls(Form1 or Control1) ; and is updating label1, also in both controls, and label1 from either controls is showing number from Class2.
Clear as mud?
How can I do this? Since Class2 must be an object in Form1 OR Control1, but not both since it will be 2 objects. Also, without making Class2 static.
Thank you.
What I have tried:
a lot of stuff since 2005..................................