本文介绍了如何覆盖Windows窗体中的关闭控件c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在form1中,我得到了:
private void button1_Click(object sender,EventArgs e)
{
Form2 form2 = new Form2();
form2.Tag = this;
form2.Show(this);
Hide();
}
然后当我点击XI时想显示前一个并隐藏当前。
解决方案
保护覆盖无效OnFormClosing(FormClosingEventArgs e)
{
if(e.CloseReason == CloseReason.WindowsShutDown)return;
//在此处进行
}
I would like to make X control closing window to hide current display previous form.
private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Tag = this;
form2.Show(this);
Hide();
}
and then when I click X I would like to show previous and hide the current.
You can override OnFormClosing to do this.
protected override void OnFormClosing(FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.WindowsShutDown) return;
// DO WHATEVER HERE
}
这篇关于如何覆盖Windows窗体中的关闭控件c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!