Hi @José Carlos Souza,
Calling Form1's header file in Form2 is a bad practice and you should avoid it. Assume the following code is implemented with a button.
frmPrincipal^ newform1 = gcnew frmPrincipal();
newform1->ShowDialog();
this->Hide();
The correct way is to add a declaration of buttonclick event in Form2.h, and then implement it in Form2.cpp. Form2.h
//Generate a click event after double-clicking the button
//modify it to a function declaration
private:
System::Void button1_Click(System::Object ^ sender,
System::EventArgs ^ e);
Form2.cpp
#include "Form1.h"
#include "Form2.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
System::Void Project50::Form2::button1_Click(System::Object ^ sender,
System::EventArgs ^ e) {
Project50::Form1^ dlg = gcnew Project50::Form1();
dlg->Show();
this->Hide();
}
Best regards,
Elya
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.