如何在C#Windows应用程序中不创建父表单的新实例的情况下返回父表单?我已经尝试过this.Parent,this.MdiParent,this.MyParentForms,但是没有人工作。
您可以在父表单中有一个用于显示其他表单的按钮。将此代码添加到按钮的Click事件中:
//Click event of your button.
private void goToSecondForm_Click(object sender, EventArgs e)
{
this.Hide(); //Hides the parent form.
subform.ShowDialog(); //Shows the sub form.
this.Show(); //Shows the parent form again, after closing the sub form.
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句