如何在 C# 中将两个表单附加在一起? [英] How do you attach two forms together in C#?

查看:28
本文介绍了如何在 C# 中将两个表单附加在一起?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
如何停靠"/附加 winforms 表单

我有两个表单:MainForm 和 PanelForm.

I have two forms: MainForm and PanelForm.

我已将其设置为通过覆盖 MainForm 的 OnMove 将 PanelForm 附加到 MainForm,以便 PanelForm 与 MainForm 一起移动.这是为了模拟 PanelForm 是 MainForm 的面板.

I have set it up so that PanelForm is attached to MainForm by overriding the OnMove of the MainForm so that the PanelForm moves along with the MainForm. This is to simulate that PanelForm is a panel for the MainForm.

我可以从 MainForm 停靠和取消停靠 PanelForm,也可以折叠它.

I can dock and undock and PanelForm from the MainForm, as well as collapse it.

问题是当我最小化 MainForm 或它失去对其他应用程序的焦点时,当我返回 MainForm 时,我必须手动 Alt-Tab PanelForm.

The problem is when I minimize the the MainForm or it loses focus to some other application, and when I return to the MainForm, I have to manually Alt-Tab the PanelForm.

有没有办法只将 PanelForm 附加到 MainForm,而不覆盖 OnMove 或其他东西来模拟它已附加?

Is there a way to just attach the PanelForm to MainForm, without overriding OnMove or other things to simulate that it is attached?

推荐答案

您不能同时拥有两个活动"窗体/窗口.但是,您可以通过激活主窗口将一个或多个窗口置于前台.为此,请使用 Form.Show(ownerForm) 覆盖.

You can not have two "active" forms/windows at the same time. However you can bring one or more windows to the foreground by activating your main window. To do this use the Form.Show(ownerForm) override.

这篇关于如何在 C# 中将两个表单附加在一起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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