private void Form1_Load(object sender, EventArgs e) { Form Form1 = this.FindForm(); Form1.Controls.Remove(this); MainScreen ms = new MainScreen(); Form1.Controls.Add(ms); }
private void Form1_Load(object sender, EventArgs e) { // Create an instance of the MainScreen MainScreen ms = new MainScreen(); // Add the User Control to the Form this.Controls.Add(ms); ms.Location = new Point((this.Width - ms.Width) / 2, (this.Height - ms.Height) / 2); }
//Return to the main screen private void continueButton_Click(object sender, EventArgs e) { // f is the form that this control is on - ("this" is the current User Control) Form f = this.FindForm(); f.Controls.Remove(this); // Create an instance of the SecondScreen MainScreen ms = new MainScreen(); // Add the User Control to the Form f.Controls.Add(ms); ms.Location = new Point((f.Width - ms.Width) / 2, (f.Height - ms.Height) / 2); }