如何在导航到新建之前隐藏用户控件的当前窗口 [英] How to hide current window from user control before navigating to new

查看:82
本文介绍了如何在导航到新建之前隐藏用户控件的当前窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在创建Windows应用程序。

我在usercontrol上添加了菜单控件,我添加了该控件我的其他形式。



现在我想要的是,从我的菜单中选择新表格时,它应隐藏或关闭优先打开的窗口然后它应该显示我下一步窗口。



但是来自菜单点击事件的用户控件的this.hide不起作用



我尝试过:



private void newToolStripMenuItem_Click(object sender,EventArgs e)

{

CallDetailsForm frmCalls = new CallDetailsForm();

frmCalls.Show();

this.Hide();

}

Hi ,

I am creating windows application.
where I have added menu control on usercontrol and i have added that control on my other forms.

Now what i want is , from my menu when i select new form , it should hide or close previosuly open window and then it should show me next window.

But this.hide from user control on menus click event is not working

What I have tried:

private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
CallDetailsForm frmCalls = new CallDetailsForm();
frmCalls.Show();
this.Hide();
}

推荐答案

您无法在usercontrol中隐藏表单 - 您无权访问它。

而是创建一个事件您的UserControl由表单处理,哪个r请求表单隐藏自己(以及另一个以后再显示)



目前,你没有明显的方法来重新显示表单 - 你可能需要处理UserControl中的CallDetailsForm.FormClosing事件,用于指示应显示的内容。
You can't hide the form from inside the usercontrol - you don't have access to it.
Instead, create an event in your UserControl which is handled by the form and which requests the form to hide itself (and another to show it again later)

At the moment, you have no obvious way of redisplaying the form - you probably need to handle the CallDetailsForm.FormClosing event within your UserControl to indicate that something should be displayed.


这篇关于如何在导航到新建之前隐藏用户控件的当前窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆