- Open C# Express 2008 and create Create a new Windows Application.
- At the properties pane on the right side of the IDE, locate the IsMdiContainer property of the form and set it to true.
- Add a MenuStrip to the form and add an item (e.g. "New Window").
- Add another form (this will serve as a child form)
- Add a textbox to the form with the following attributes: Multiline = true, Dock=fill;
- Go back to the main form and double click the first item on the MenuStrip to view the code.
- Type in the following code (use Form2 if that's the name of your second form):
Form2 newForm2 = new Form2();
newForm2.MdiParent = this;
newForm2.Show();
- The code should look like this:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void newWindowToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 newForm2 = new Form2();
newForm2.MdiParent = this;
newForm2.Show();
}
}
Run the program by pressing F5
Comments