ArgumentException when adding a form to a panel

G

Guest

Hi,

I have the following code, that worked OK with Visual Studio 2003:

Form2 v_Frm2 = new Form2();
m_pnlForms.Controls.Add(v_Frm2);
v_Frm2.Show();
v_Frm2.BringToFront();

It makes Form2 to appear inside a panel inside Form1. However, this same
code when running in Visual Studio 2005 (.net cf 2.0) gives the exception
described bellow. Does anyone know what is wrong, or how should I change my
code?

System.ArgumentException was unhandled
Message="Value does not fall within the expected range."
StackTrace:
at Microsoft.AGL.Common.MISC.HandleAr()
at System.Windows.Forms.Control._SetParent()
at System.Windows.Forms.Control.set_Parent()
at ControlCollection.Add()
at NestedForms.Form1.Form1_Load()
at System.Windows.Forms.Form.OnLoad()
at System.Windows.Forms.Form._SetVisibleNotify()
at System.Windows.Forms.Control.set_Visible()
at System.Windows.Forms.Application.Run()
at NestedForms.Program.Main()
 
G

Guest

Just to emphasize: We are dealing with *COMPACT* framework here...

Regis Fontes said:
Hi,

I have the following code, that worked OK with Visual Studio 2003:
(...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top