Click here to Skip to main content
15,907,906 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Form1:
C++
#pragma once
#include "Form2.h"
namespace Show {
           private: System::Void button1_Click(System::Object^sender, System::EventArgs^  e)          
            {
              this->Hide();
              Form^frm2=gcnew Form2();
               frm2->Show();
			 }
	};
}


Now i want to show Form1 again when Form2 is closed:
C++
#pragma once
#include "Form1.h"
......
private: System::Void Form2_FormClosed(System::Object^  sender, System::Windows::Forms::FormClosedEventArgs^  e) {
			Form^frm1=gcnew Form1();
                        frm1->Show();
		 }
......


But it's not okay. The error is about the declaration. Warned is that Form1 not declared!

Could you guys tell me what's wrong?
Thank you all!
Posted
Updated 23-Aug-12 21:12pm
v2
Comments
Sergey Alexandrovich Kryukov 24-Aug-12 15:40pm    
OK, form is node declared... what kind of logic do you have when you say that it's related to "hidden"?!
There is no such thing as "declare a hidden". The question makes no sense at all. Show/Hide is run-time, not declaration.
Make sure your declaration is visible. Besides, the whole thing makes little sense. Why would you close one form and hide another one, with a local variable of new -- it won't be accessible beyond the declaration. If you did not understand it, it's beyond help; you first need to learn basics like variables/members/types and instances, etc....
--SA
christmars 27-Aug-12 1:47am    
ok, firstly thank you so much. knowing it's not possible is already helpful. i am a beginner:). But i would try to code a variable like you mean.
Maciej Los 25-Aug-12 10:51am    
Your logic:
1) start app (Form1)
2) when you click on the button1, you are hiding Form1 and you are showing Form2
3) on closing Form2, you want to show(unhide) Form1
Am i right?
christmars 27-Aug-12 1:41am    
yes you got it.
Maciej Los 27-Aug-12 3:43am    
Sergey's comment is very important and usefull for the future. Your code looks fine, but - in my opinion - the problem is in the declaration of Form1. Check the correct name of header file for the Form1. Maybe you've changed it. The caption, title of window (Form1) is not equal with its name.

1 solution

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