I have 4 forms in my program:
- StartForm
- UIForm1
- UIForm2
- DebugForm
I start the program with StartForm, then user can use buttons to start UIForm1 and 2. There is also another form called DebugForm that there is a textBox in it and I put all errors duruing using UIForm1 and 2 inside it (Exceptions and etc..).
No I want to declare DebugForm in StartForm so UIForm1 and 2 can both access it. How can I do it? I tried declaring it as public but it cant be accessed:
//in StartForm
public DebugForm dFrm = new DebugForm(); //Not working
//in UIForm1 or 2
//add a error to textbox
dFrm.textBox.Text += "ERROR NUMBER 1"; //Not working
dFrm.Show(); //Not working
I suspect I have to do it somehow with delegate keyword. How it will be possible to do so?
A quick-fix would be to declare the DebugForm variable in StartForm as:
And use it in your other forms as: