In that case you REALLY don't want to be accessing your 'Output" richtextform directly from a bunch of other forms. It just makes it a mess to maintain.
You want to make a custom event that your Output window listens for. Whenever it hears the event it reacts by putting the text of the eventarg into the richtext box.
Think of your program as a bingo parlor. The events are the man picking the numbers. He just yells out N-15 and all the players hear him and respond by checking the bingo cards. The players all subscribe to the event of:
Caller.yells(PickedNumber);
The caller doesn't know anything about the players or their game cards. He has one job, yell the numbers. It doesn't matter if 1 person is playing or 100.
I suggest you first make a generic form with all your custom but commonly shared code it in. This form will have a custom event something like "LogThis" or "ReportThis"
Now when you make all of your other children forms, make them inherit from that common form that already has the event. This way *they* inherit that event.
When your Mainform makes newforms it can do something like this...
-
MyCustomForm child1 = new MyCustomForm();
-
child1.LogThis += new LogThis(LogThisMethodHandler);
-
-
MyCustomForm child2 = new MyCustomForm();
-
child2.LogThis += new LogThis(LogThisMethodHandler);
-
-
MyCustomForm child3 = new MyCustomForm();
-
child3.LogThis += new LogThis(LogThisMethodHandler);
-
Now you have 3 new child forms, all inherited from the custom form with the LogThis Event. Your MainForm is subscribed to each child's LogThis event.
When a child yells "LogThis" the parent responds in the LogThisMethodHandler method.
The children only know they need to yell "LogThis". They don't know *how* the parent is going to log it. They don't have to. They are children. Its not their place to tell the parent how to react.
The parent has one reaction to all the children: It logs when they yell.
If you later change your logging to include writing to file in addition to displaying in the richtextbox you only have to make the update in the one method of the parent - not in all the child forms.