如何在C#中弹出窗口 [英] How to popup window in C#
本文介绍了如何在C#中弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我现在在Visual Studio中开发一个窗口窗体.我的项目中有两种形式.当我单击在Form1中显示按钮时,它将弹出form2,但是我做不到.请帮助我任何解决方案.
Hi all,
I am now developing a window form in Visual Studio. there are two form in my project. When I click button show in Form1 then It will popup the form2, but I cannot do it. Please help me any solution. Thank you in advance.
推荐答案
在Form1
中按钮的按钮单击事件上,创建Form2
的实例,请执行以下代码.
On button click event of button inForm1
, make an instance of yourForm2
, do the below codes.
Form2 form2 = new Form2();
form2.Show();
如果这解决了您的问题,请标记为答案并投票5
问候,
爱德华
Please mark as answer and vote 5 if this solved your problem
Regards,
Eduard
在窗体1的按钮单击事件中输入以下代码
in form 1 button click event enter the following code
{
form2 frm = new form2(); //it will initialize the object frm for form 2 in form 1
frm.Show();// this will opening form 2
//if you want to hide form 1 then
this.Hide();
}
尝试一下.
在button_Click事件中,
try this.
inside the button_Click event,
form2.show();
希望对您有帮助
别忘了投票
谢谢
hope it helps
don''t forget to vote
thank
这篇关于如何在C#中弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文