1

在我的独奏中,我创建了一些项目,其中一个是主项目,因此它会在应用程序启动时启动。

我只想使用这个主项目的属性文件来存储所有属性(字符串、对象等),所以对于这种情况,我必须在其他表单项目中引用这个主表单项目(希望我有意义!)

现在的问题是当我想在我的主表单项目中调用其中一个表单时,因为我无法引用它们(我收到此循环依赖警告),我无法这样做!在这种情况下有什么解决方法?

4

2 回答 2

0

You can only link in one direction. You must think of a project as a upside down tree. You can reference a parent class, but the parent class can't reference the children class. So if you need a feature that is needed in both, move it to the parent of the two classes, or move it to a 3rd class, and both reference it.

于 2012-07-14T00:01:42.913 回答
0

当您在主窗体中调用其中一种窗体时,您将主窗体实例作为构造函数参数传递。通过这种方式,您可以访问主项目的属性。主要形式必须是其他形式的先例。除非您将所有属性作为独立的类或构造,否则另一种方法将不起作用

于 2012-07-14T05:22:45.027 回答