I am a newbie to vs.net and I am trying to create a child MDI form. Now, I use this code to open a new child form:
This is taken almost character for character from theVS.net help.
I have seen a million examples of this exact method on the web.
But, when I try to Debug (F5), I get this error:
C:\...\Form1.cs(329): 'temp.Form2' does not contain a definition for 'MDIParent'
Any ideas? I generated the form by right clicking on the solution
in the Solution Explorer and doing Add > Windows Form > etc.
Within Form2, I have tried to manually set the MdiParent property
but I can't. I have tried this line of code:
this.MdiParent = Form1;
That fails for obvious reasons, but I was willing to try anything.
Hope you can help me out. I'm sure I'm missing something
obvious, but I followed the VS.net "tutorials" to the letter and it
just plain doesn't work and I can't figure it out! Thanks!
Here is the code for Form2 (in case it matters):
C#:
private void menuItem2_Click(object sender, System.EventArgs e)
{
Form2 newMDIChild = new Form2();
newMDIChild.MDIParent = this;
newMDIChild.Show();
}
I have seen a million examples of this exact method on the web.
But, when I try to Debug (F5), I get this error:
C:\...\Form1.cs(329): 'temp.Form2' does not contain a definition for 'MDIParent'
Any ideas? I generated the form by right clicking on the solution
in the Solution Explorer and doing Add > Windows Form > etc.
Within Form2, I have tried to manually set the MdiParent property
but I can't. I have tried this line of code:
this.MdiParent = Form1;
That fails for obvious reasons, but I was willing to try anything.
Hope you can help me out. I'm sure I'm missing something
obvious, but I followed the VS.net "tutorials" to the letter and it
just plain doesn't work and I can't figure it out! Thanks!
Here is the code for Form2 (in case it matters):
C#:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace temp
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.RichTextBox richTextBox1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form2()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(292, 273);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
//
// Form2
//
this.AccessibleName = "Form2";
this.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.richTextBox1});
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);
}
#endregion
private void richTextBox1_TextChanged(object sender, System.EventArgs e)
{
}
}
}
Last edited by a moderator: