标签:baidu send 调用 nts 变化 key comm tty protected
Form2 f2 = new Form2();
f2.Show();
protected override void Dispose(bool disposing)
{
Hide();
//if (disposing && (components != null))
//{
// components.Dispose();
//}
//base.Dispose(disposing);
}
(注意:在子窗口Designer文件中修改)
子窗口类中添加的关闭函数如下:
public void Close()
{
this.Dispose();
}
父窗口关闭是销毁子窗口对象,因此,在父窗口的关闭动作FormClosed中添加调用子窗口f2的销毁函数。
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
f2.Close();
}
===================================================================================
另外还有一种方式:
父窗体
public void ShowPopWindow()
{
TestA sub = new TestA();
sub.CloseWindow += new Action(sub_CloseWindow);
sub.show();
}
void sub_CloseWindow()
{
//改变父窗体控件内容
}
子窗体
public class TestA
{
public event Action CloseWindow;
protected virtual void OnCloseWindow()
{
Action handler = CloseWindow;
if (handler != null) handler();
}
//子窗体关闭事件
private void CloseSubWindow()
{
OnCloseWindow();
}
}
出处:https://zhidao.baidu.com/question/134623114688436765.html
========================================================================
标签:baidu send 调用 nts 变化 key comm tty protected
原文地址:https://www.cnblogs.com/XuPengLB/p/9560574.html