I have a project that consist of 2 Forms. I am trying to open Form2 with this code but when I compile the project I have this compile error and wonder what this meens and why it doesn´t work.

cannot convert from 'System::Windows::Forms::Form ^' to 'Form1::Form2 ^

1> No user-defined-conversion operator available, or
1> Cast from base to derived requires safe_cast or static_cast

#include "Form2.h"


Form2^ newform2 = gcnew Form;
newform2->ShowDialog();

Recommended Answers

All 2 Replies

Try this:

#include "Form2.h"


Form2^ newform2 = gcnew Form2;
newform2->ShowDialog();

Yes ofcourse, that was the problem. Thank you... !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.