将一个窗体移动到另一个 winform - C#
我有2个winforms Form 1和Form 2。我在form1中有button1,当我从form1单击button1时,我显示form2。
Form2 ins = new Form2();
ins.MdiParent = this.MdiParent;
this.Hide();
ins.ShowDialog();
当单击button1时,我隐藏form1以显示form2。这会产生闪烁效果,我需要消除这种闪烁。我如何打开/重定向到另一个表单(我应该一次只显示一个表单,并且不应该显示任何顶部菜单,例如(如果我使用 MDIParent 表单)。只有一个活动表单。
谢谢, 卡西克
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();
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.
Thanks,
Karthick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这听起来有点像您正在尝试创建一个 Web 风格的 UI,其中用户从一个“页面”(由表单表示)步进到另一个“页面”。
与其使用单独的表单实现这样的 UI,不如使用托管在单个父表单上的 UserControls 来实现。
请阅读这篇 MSDN 文章,其中包含示例代码的下载。这是设计此类用户界面的一个很好的演练:
IUI 和 Web 样式导航Windows 窗体,第 1 部分
Windows 窗体中的 IUI 和 Web 样式导航,第 2 部分
编辑
如果您打算显示两个单独的表单,是否有任何理由需要以模态方式显示第二个表单?你能不能简单地显示它然后隐藏原来的?
...或者您是否还有另一种形式,form1 和 form2 都是“模态”的?
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.
Rather than implementing a UI like this with separate forms, you're better off doing it with UserControls hosted on a single parent form.
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:
IUIs and Web-Style Navigation in Windows Forms, Part 1
IUIs and Web-Style Navigation in Windows Forms, Part 2
Edit
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?
... or do you have yet another form that both form1 and form2 are "modal" to?
从一个页面 (
form1
) 转移到另一页面 (form2
)假设
form1
包含一个名为“SAVE”的按钮我们必须在“SAVE”按钮的单击事件中编写以下代码
To transfer from one page (
form1
) to another (form2
)suppose
form1
contain a button named "SAVE"we have to write the following code in click event of the "SAVE" button
我认为 winforms 上有一个属性,如果你想在任务栏上显示它或不显示它。
I think there is a property on winforms if you would like to show it on the task bar or not.
我可以澄清您对如何从 form1 重定向到 form2 的疑问,
例如:
在form1中放置一个链接,然后在其中写入以下代码
I can clarify your doubt about how to redirect from one form1 to form2
for example:
place a link in form1 and then write following code in it
使用关闭选项代替隐藏。
或者简单地
Instead of hide use close option.
or simply