Microsoft Visual Linking Forms/Projects [英] Microsoft Visual Linking Forms/Projects

查看:25
本文介绍了Microsoft Visual Linking Forms/Projects的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个包含四个项目的解决方案.在 Project_Owner_Add 中,我想要一个 Next 按钮,以便在单击时显示其他项目之一.

So I have one Solution with four Projects in it. In Project_Owner_Add I want a Next button so that when it is clicked one of the other Projects is displayed.

这是我的代码.

private void buttonNext_Click(object sender, EventArgs e)
{
    Project_Owner_Add.Form1 next = Project_Owner_Add_Product_Owner.Form1();
    next.Show();
}

错误信息如下:

Project_Owner_Add_Product_Owner 在当前上下文中不存在

Project_Owner_Add_Product_Owner does not exist in the current context

我假设我要从一个单独的项目中调用信息都是错误的,但我有点认为这只是将表单链接在一起的问题(这也不起作用).

I'm assuming I'm going about calling information from a separate Project all wrong but I had sort of thought it was a matter of simply linking the forms together (this also doesn't work).

关于如何解决这个问题有什么建议吗?

Any suggestions on how to get around this?

推荐答案

按照已经建议的方式添加对其他项目的引用,您也可以使用 using 指令为您的 Form1 设置一些别名 类,以防它在两个项目中都存在.

Add reference to your other project as already suggested, also you can use using directive to set some alias for your Form1 class in case when it exists in both projects.

在 C# 中实例化类时,关键字 new 是必不可少的.你可以这样做:

The keyword new is essential when it comes to instantiating classes in C#. You can do something like this :

如果需要,添加对其他项目的引用 -> 然后:

Add reference to other project if needed - > then :

using MyForm = Project_Owner_Add.Form1;

private void buttonNext_Click(object sender, EventArgs e)
{
    MyForm next = new MyForm();
    next.Show();
}

这篇关于Microsoft Visual Linking Forms/Projects的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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