如何从另一个项目中打开一个新表单 [英] How to open a new form from another project

查看:93
本文介绍了如何从另一个项目中打开一个新表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从另一个项目表单按钮单击事件

How to open a new form from another project form button click event

推荐答案

打开新表单没有打开表单这样的事情。 (是的,术语有误导性。有关闭,但没有一种形式方法打开它。你需要抱着幻想而不是假设API中的所有东西都是根据你对事物的直观理解命名的;它可以背叛你可以创建一个表单实例并显示它,这就是全部:

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.show.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/szcefbbd.aspx [ ^ ](很少有道理),

http://msdn.microsoft.com/en-美国/库/c7ykbedk.aspx [ ^ ],

http://msdn.microsoft.com/en-us /library/w61zzfwe.aspx [ ^ ]。



您对项目的理解情况更糟。一个项目实际上是一些数据集指示编译器(有时还有一些其他工具)来构建源代码中的程序集。在运行时没有项目,但CLR和主要单元的核心概念是汇编。使用Visual Studio,每个项目都会创建一个由一个可执行的模块组成的程序集。 (编译器允许创建由一个或多个模块组成的程序集,但默认情况下Visual Studio不支持它。)一个程序集可以引用其他程序集;引用的程序集作为引用它的程序集的共享类库单元。基本上,这就是全部。



构建应用程序时,它可以是引用其他程序集的程序集,每个引用的程序集都可以引用其他程序集。这几乎是无关紧要的,什么类写在什么集合中;交叉装配可见性由 public protected 访问修饰符控制,这就是全部。如果引用第一个程序集,则可以在一个程序集中编写Form类,并在另一个程序集中创建此时的表单实例。没有必要问如何。 与单个组件的情况完全相同。



-SA
There is no such thing as "open a form". (Yes, terminology is misleading. There is "close", but none of the form methods "opens" it. You need to hold you fantasy and not assume the everything in API is named according to your intuitive understanding of things; it can betray your.) You can create an instance of the form and show it, that''s all:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.show.aspx[^],
http://msdn.microsoft.com/en-us/library/szcefbbd.aspx[^] (rarely makes sense),
http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx[^],
http://msdn.microsoft.com/en-us/library/w61zzfwe.aspx[^].

The situation with your understanding of "projects" is even worse. A project is actually some data set instructing compiler (and, sometimes, some other tools) to build an assembly out of source code. There are no "projects" during runtime, but the central notion of the CLR and the main unit is assembly. With Visual Studio, each project creates a single assembly consisting of one single executable module. (Compilers allow to create an assembly made of one or more of modules, but Visual Studio does not support it by default.) One assembly can reference others; and the referenced assembly serves as a shared class library unit to the assembly referencing it. Basically, that''s all.

When an application is built, it can be an assembly referencing other assemblies, and each of referenced assemblies can reference some other ones. It''s nearly irrelevant, what classes are written in what assemblies; the cross-assembly visibility is controlled by public and protected access modifiers, that''s all. You can write a Form class in one assembly, and create a form instance of this time in another one, if you reference the first assembly. There is no need to ask how. In exact same way as in the case of a single assembly.

—SA


这篇关于如何从另一个项目中打开一个新表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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