Create an instance of a form

G

Guest

Hello
I'd like to create and affich an instance of the form "Form2" as a mdichild
of the actual form.
In C#.net, I know that is like this :

Form2 MyForm=new Form2();
MyForm.MdiParent=this;
MyForm.Show();

But I'd like to do it in C++.NET
I think that the first line is :

Form2 ^ MyForm=gcnew Form2();

please help me to complete this code
thanks
 
I

ismailp

I didn't use MDI child so far, in .NET, but let me give a shot.

Before my comment, please check your compiler; are you using C++/CLI
(Visual Studio 2005) or Managed Extensions for C++ (Visual Studio 2002,
Visual Studio 2003)?

If you are using C++/CLI, the above declaration of Form2 is fine.
Otherwise, for the latter case, you need to do this:

Form2* MyForm = new Form2();

The rest is almost identical to C# equivalent of the code, except those
dots (.) should be replaced with arrows (->).

MyForm->MdiParent = this;
MyForm->Show();

Ismail
 
G

Guest

Hello
I use Visual C++.NET 2005 Beta2.
The project type is "CLR:Windows Forms Application"
When I use this code :

Form2* MyForm = new Form2();
MyForm->MdiParent = this;
MyForm->Show();

The compiler signals these errors :

error C2039: 'MdiParent' : is not a member of 'System::Enum'
error C2039: 'Show' : is not a member of 'System::Enum'

And when I use this code :

Form2^ MyForm = gcnew Form2();
MyForm->MdiParent = this;
MyForm->Show();

The compiler signals these errors :
error C2039: 'MdiParent' : is not a member of 'System::Windows::Forms::Form2'
error C2039: 'MdiParent' : is not a member of 'System::Windows::Forms::Form2'

Please help me
 

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