以编程方式从另一个表单中打开一个窗口表单 [英] opening a window form from another form programmatically
本文介绍了以编程方式从另一个表单中打开一个窗口表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作Windows窗体应用程序.我有一个表格.我想在运行时通过单击按钮从原始表单中打开新表单.然后以编程方式但从gui主线程以外的其他线程中关闭此新表单(在2,3秒后).
I am making a Windows Forms application. I have a form. I want to open a new form at run time from the original form on a button click. And then close this new form (after 2,3 sec) programatically but from a thread other than gui main thread.
- 有人可以指导我怎么做吗?
- 新形式会影响或阻碍原始主要形式中发生的事情吗?(如果是,如何阻止它?)
推荐答案
要通过按钮单击打开,请在按钮事件处理程序中添加以下代码
To open from with button click please add the following code in the button event handler
var m = new Form1();
m.Show();
Form1是您要打开的表单的名称.
Here Form1 is the name of the form which you want to open.
也可以使用
this.close();
这篇关于以编程方式从另一个表单中打开一个窗口表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文