Hi all,

I am new to programming and having been experimenting various codes recently.

I have managed to link 2 form so that when i click a button on Form1, Form2 opens.
I am using the code

Form2^open2 = gcnew Form2();
             open2->Show();

This codes work fine.

Is there a way of opening Form2 so that Form1 closes or so it replaces Form1?

Many Thanks

http://www.daniweb.com/software-development/cpp/threads/341509
Props to AD for this one. I upvoted his post. You should do the same.

Thank you DeanMSands3.

I have used the code below which work brilliantly.

Form2^open2 = gcnew Form2;
this->Hide();
open2-> Show();

I am new to programming and I want to try to understand the code instead of just using it without some reasoning.

Could someone please explain why "^" and "gcnew" is used for?
I understand the 2nd and 3rd line of the code.

I find it much easier by doing an excercise and learning the codes instead of reading a book.

Many Thanks

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.