I have a WinForm with modular/dockable subforms (WeifenLuo). What is best practice to pass events/information between the forms?
For example: I want a "SelectionChanged" event in SubForm1 change what is highlighted in SubForm2. Problem is, there might be zero SubForm2-Tabs, one or multiple instances.
Currently, if a new instance of a SubForm is requested by the user, a function like this is called:
private void toolStripMenuItemSubForm1_Click(object sender, EventArgs e)
{
SubForm1 subForm1 = new SubForm1();
subForm1.Show(dockPanelMain, DockState.Document);
}
The MainForm has no record of all subforms except dockPanelMain.Contents
.
Edit: I know how forms can interact with each other and how events per se work. My problem is that a event from SubForm1 can alter different other SubForms, but they might not exist at a given point in time, or there might be multiple instances and I dont want to chain it through the MainForm for every single event.