将表单停靠到另一个表单面板
是否可以将 form1 停靠到另一个 form2 中包含的面板? 我正在从 form2 事件中使用 ShowDialog 启动 form1。
Is it possible to dock a form1 to a panel contained in another form2?
I'm launching form1 with ShowDialog from a form2 event.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不使用
ShowDialog
(甚至Show
),不。已经显示为顶级窗体的窗体以后不能添加为任何其他控件的子控件。您可以尝试通过监视LocationChanged
事件将表单保持在一组特定的屏幕边界内,但这会在屏幕上显得不稳定。Not with
ShowDialog
(or evenShow
), no. A form that has already been displayed as a top-level form cannot later be added as a subcontrol of any other control. You can try to keep the form within a particular set of screen bounds by monitoring theLocationChanged
event, but that will appear jerky on the screen.考虑将
form1
中的控件提取到 UserControl 中。在form1
上使用该 UserControl(假设您需要它作为表单以及停靠控件),然后将 UserControl 停靠在form2
上以实现所需的功能。Consider extracting the controls out of
form1
into a UserControl. Use that UserControl onform1
(assuming you need it as a form as well as the docked control), then dock the UserControl onform2
to implement the desired functionality.考虑使用完全免费的对接库来开发此链接提供的 Visual Studio .Net 样式应用程序。相信我,这是商业质量且无错误的代码!
Consider using the COMPLETELY FREE docking library to develop Visual Studio .Net style applications provided by this link. Believe me, it's a commercial quality and bug-free code!