我可以将表单用作其他表单中的组件吗? [英] Can i use a Form as a Component in another Form

查看:140
本文介绍了我可以将表单用作其他表单中的组件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中有一些表格.我想在Designer中将Form1的实例添加到Form2.可以在Form1中实现IComponent接口,但是我看不到工具箱中的Form1将其添加到Form2中.有什么主意吗?
谢谢

I have some Forms in my Project. I''d like to add an instance of Form1 to Form2 in Designer. It is possible to implement the IComponent Interface in Form1 but i can''t see Form1 in the Toolbox to add it to Form2. Any idea?
Thanks

推荐答案

它永远不会显示在您的工具框中.如果要添加,则可以使用UserControl,它提供了几乎所有功能,也将出现在工具箱中.
It will never be displayed in your tool box. If you would like to add then you can use UserControl it provides almost all function and also will appear in your toolbox.
that would be a good practice.


回答您的主题行,是的,您可以.

正如Ravi所说,不是在设计时就回答您的问题.

如果创建包含Form1中所有控件和逻辑的UserControl:
1)将在工具箱中提供
2)您可以将其用于Form1和Form2.
In answer to your subject line, yes you can.

In answer to the body of your question, as Ravi has said, not at design time.

If you create a UserControl containing all the controls and logic from Form1:
1) it will be available in the Toolbox
2) you can use it for Form1 and Form2.


但不可能将其保留为Form(因为我需要一些Form事件)并在工具箱中将其保存为一个组件.就像一个计时器.我不需要仅在设计器中对其进行设计即可使用它的属性吗?
But isn''t there a possibility to leave it a Form (Because i need some Form events) and get it in the toolbox as a componenten. Like a timer. I don''t need to design it in the designer its just so that i can use it''s properties?


这篇关于我可以将表单用作其他表单中的组件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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