Winforms 在窗体之间切换 [英] Winforms switching between forms
本文介绍了Winforms 在窗体之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在正在使用 winforms.我有一个主表单form1",我有一个打开 form2 的按钮.当我打开 form2 时,我希望 form1 消失.当用户单击 form2 上的 x 按钮时,我希望它关闭并返回到 form1.我不想使用模态窗口.
I'm using winforms now. I have the main form "form1" and I have a button that opens form2. When I open form2 I would like for form1 to disappear. When the user click the x button on form2 I would like for it to close and go back to form1. I wouldn't like to use modal windows.
推荐答案
private void button1_Click(object sender, EventArgs e) {
var frm = new Form2();
frm.Location = this.Location;
frm.StartPosition = FormStartPosition.Manual;
frm.FormClosing += delegate { this.Show(); };
frm.Show();
this.Hide();
}
这篇关于Winforms 在窗体之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文