问题描述
限时送ChatGPT账号..我有 2 个 winform,Form 1 和 Form 2.我在 form1 中有 button1,当我从 form1 单击 button1 时,我会显示 form2.
I have 2 winforms Form 1 and Form 2. I have button1 in form1, when i click on button1 from form1 i display form2.
Form2 ins = new Form2();
ins.MdiParent = this.MdiParent;
this.Hide();
ins.ShowDialog();
当单击 button1 时,我隐藏 form1 以显示 form2.这会产生闪烁效果,我需要删除这种闪烁.我如何打开/重定向到另一个表单(我应该一次只显示一个表单,而不应该显示任何顶部菜单(如果我使用 MDIParent 表单).只有一个活动表单.
I hide the form1 to display form2 when button1 is clicked. This creates a flicking effect and i need to remove this flicking. How do i open/redirect to another form (i am supposed to show only one form at a time and am not supposed to show any top menu like (if i use MDIParent form). Just one active form.
谢谢,卡西克
推荐答案
这听起来有点像您正在尝试创建一个 Web 样式的 UI,让用户从一个页面"(由表单表示)移动到另一个页面".
It sounds a bit like you're trying to create a web-style UI where the user steps from one "page" (represented by a Form) to another.
与其使用单独的表单实现这样的 UI,不如使用托管在单个父表单上的 UserControl 来实现.
Rather than implementing a UI like this with separate forms, you're better off doing it with UserControls hosted on a single parent form.
阅读这篇 MSDN 文章,其中包含带有示例代码的下载.这是设计此类用户界面的绝佳演练:
Have a read of this MSDN article, which includes a download with sample code. It's a great walkthrough for designing that kind of user interface:
Windows 窗体中的 IUI 和 Web 样式导航,第 1 部分
Windows 窗体中的 IUI 和 Web 样式导航,第 2 部分
编辑
如果您打算显示两个单独的表单,是否有任何理由需要以模态方式显示第二个表单?不能简单的显示出来然后隐藏原件吗?
If you're intent on showing two separate forms, is there any reason you need to show the second one modally? Can you not simply show it and then hide the original?
form2.Show();
form1.Hide();
... 或者您是否还有另一种形式,form1 和 form2 都是模态"?
... or do you have yet another form that both form1 and form2 are "modal" to?
这篇关于将一个窗体移动到另一个 winform - C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论