开发者

Show form from another form

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜