Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am building a project in visual c++ clr form application and i added a new form to the project but i can't call it using this code

ex: form2->show();
or project_namespace::form2::show();

help?
Posted
Updated 21-Mar-11 8:05am
v3
Comments
Olivier Levrey 21-Mar-11 11:45am    
what is the error message?

You're trying to call instance method on class. Class is a type, instance is an object. Only static methods and properties are called on classes; static methods and properties are called on instances. The difference is: each instance method has implied (invisible) "this" parameter which gives access to instance data (and hence other instance methods and properties). You need to declare an object as a variable or create an object with gcnew to have an instance to call instance methods or properties.

I feel you need to step back to basics before you get to UI development.

—SA
 
Share this answer
 
Below are two examples on how to create an instance of your form2 class.

form2 ^myform = gcnew form2();
myform->Show();

or
(gcnew form2())->Show();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900