I have button on form3 that once clicked shows a new usercontrol on form1. However, the usercontrol has a number of buttons that I would like to be child forms of form1 (Form4 newMDIChild = new Form4(); newMDIChild.MdiParent = this.MdiParent;
newMDIChild.Show(); does not work). Unfortunatley, I cannot seem to figure out how to make the usercontrol a child or to let the usercontrol know who the child forms parent is.
This is what I have so far.
Thanks in advance!!!!!
Button Form
Expand|Select|Wrap|Line Numbers
- public partial class Form3 : Form
- {
- public Form3()
- {
- InitializeComponent();
- }
- protected void Show (Control control)
- {
- Form1 form = (Form1)Application.OpenForms["Form1"];
- form.Controls.Add(control);
- form.Show();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- UserControl1 userControl = new UserControl1();
- Form3 form = new Form3();
- form.Show(userControl);
- }
- }
- }