Hej
Jeg har Form1 og Form2, jeg ved at man kan åbne Form2
fra Form1 på følgende måde.
private void settingsBtn_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Show();
}
Jeg har prøvet at søge efter en løsning på google, hvor jeg fandt følgende måde.
public Form1()
{
InitializeComponent();
startMenu.Hide();
Form2 f2 = new Form2();
f2.Show();
f2.MdiParent = this;
}
Men når jeg prøver det får jeg følgende fejl
System.ArgumentException was unhandled
Message=Form that was specified to be the MdiParent for this form is not an MdiContainer.
Parameter name: value
Source=System.Windows.Forms
ParamName=value
StackTrace:
at System.Windows.Forms.Form.set_MdiParentInternal(Form value)
at System.Windows.Forms.Form.set_MdiParent(Form value)
at WindowsFormsApplication1.Form1..ctor() in C:\Documents and Settings\andreas\Local Settings\Application Data\Temporary Projects\WindowsFormsApplication1\Form1.cs:line 22
at WindowsFormsApplication1.Program.Main() in C:\Documents and Settings\andreas\Local Settings\Application Data\Temporary Projects\WindowsFormsApplication1\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
i denne linje f2.MdiParent = this;
Er der nogle som kan hjælpe mig lidt videre her?