All I can understand is that you have several WinForm
s and you want some main Form to control them? Well, if I understanding/assumption is correct, then about controlling like following?
public partial class Form3 : Form
{
private void Form3_Load(object sender, EventArgs e)
{
Demo();
}
MyMainForm main = new MyMainForm(); //Your actual form
private void Demo()
{
main.Click += new EventHandler(main_Click);
main.ShowDialog();
}
void main_Click(object sender, EventArgs e)
{
MyNotificationForm notify = new MyNotificationForm();//Your notification form
notify.Name = "notify";
notify.Click += new EventHandler(notify_Click);
notify.ShowDialog(main);
}
void notify_Click(object sender, EventArgs e)
{
MyWarningForm warning = new MyWarningForm();//Your warning form
warning.Click += new EventHandler(warning_Click);
warning.ShowDialog(main.ActiveMdiChild);
}
void warning_Click(object sender, EventArgs e)
{
((Form)sender).Close(); //Click on form would close this.
}
}
Following is how I'd implement the classes.
public class CBaseForm : Form
{ public CBaseForm() { this.Text = "Main App"; } }
public class MyWarningForm : CBaseForm
{ public MyWarningForm() { Label lbl = new Label(); lbl.Text = "Warning Form"; this.Controls.Add(lbl); } }
public class MyNotificationForm : CBaseForm
{ public MyNotificationForm() { Label lbl = new Label(); lbl.Text = "Notification Form"; this.Controls.Add(lbl); } }
public class MyMainForm : CBaseForm
{ public MyMainForm() { Label lbl = new Label(); lbl.Text = "Controller Form"; this.Controls.Add(lbl); } }
And you MainForm
would start conventionally
Application.Run(new Form3());
Let me know if I dragged your question to 180 degrees!