In .net Compact Framework 2.0, you could add a form to another forms control array basically parenting the other form.
i.e._mainForm.Controls.Add(form);
This is not allowed in .net cf 3.5 and results in an exception:
System.ArgumentException: Value does not fall within the expected ra开发者_开发问答nge.
at Microsoft.AGL.Common.MISC.HandleAr(PAL_ERROR ar)
at System.Windows.Forms.Control._SetParent(Control ctlParent)
at System.Windows.Forms.Control.set_Parent(Control value)
Is there a workaround or alternative for this? I need to be able to parent a form inside a panel on another form.
I think this contains answer to your question: http://207.46.16.248/en-us/netframework/bb986636.aspx
especially this part:
System.Windows.Forms.Form.Parent
Description Forms can no longer be parented.
Previous Behavior
In .NET Compact Framework 1.0, forms could be parented to any other control
that supported child controls. In .NET Compact Framework 2.0, forms
could be parented to any other form.
New Behavior
In the .NET Compact Framework version 3.5, forms cannot be parented.
You can use the following method to copy form controls to another form in .NET CF 3.5
// Clear old form controls
oldform.Controls.Clear();
// Copy controls from newform to oldform
foreach (Control ctl in newform.Controls)
{
oldform.Controls.Add(ctl);
}
精彩评论