using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
private void FormMain_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
this.IsMdiContainer = true;
FormA frmFormA = new FormA();
frmFormA.frmMain = this;
frmFormA.Show();
}
}
public class FormA : Form
{
private Button b;
private FormA frmFormB;
public FormMain frmMain;
public FormA()
{
this.TopMost = true;
this.MdiParent = frmMain;
b = new Button();
b.Text = "Open Form";
b.Location = new Point((this.Width - b.Width) / 2, (this.Height - b.Height) / 2);
b.Click += new EventHandler(b_Click);
this.Controls.Add(b);
}
void b_Click(object sender, EventArgs e)
{
frmFormB = new FormA();
frmFormB.Show();
this.Close();
}
}
}