开发者

Show form from another form

开发者 https://www.devze.com 2023-01-16 17:02 出处:网络
Ihave 2 forms Form1 and Form2. How can I, inside code (Form1.h) show Form2 (something l开发者_开发技巧ike Form2::Show())Edit your .cpp file and arrange the #include directives, putting the 2nd form fi

I have 2 forms Form1 and Form2. How can I, inside code (Form1.h) show Form2 (something l开发者_开发技巧ike Form2::Show())


Edit your .cpp file and arrange the #include directives, putting the 2nd form first:

#include "stdafx.h"
#include "Form2.h"
#include "Form1.h"

Then write code like this in, say, a button's Click event handler:

    System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
        Form2^ frm = gcnew Form2;
        frm->Show(this);
    }


You need to create a new instance of the Form2 class and call its Show() method.

0

精彩评论

暂无评论...
验证码 换一张
取 消