无法从主窗口调用Windows表单

时间:2018-11-26 05:44:44

标签: c# winforms constructor

我试图从我的主窗口调用Windows窗体(SortpBoundaryImages),但它返回“找不到类型或名称空间名称'SortpBoundaryImages'(您是否缺少指令或程序集引用)?

using System.Windows.Forms;

namespace DataCollection
{
public class Layers
{
    [CommandMethod("CivilData")]

    public static void Main()
    {

        Form sortP = new SortpBoundarImages();
}}}

这是我在单独的.cs文件中的表单代码。

using System;
using System.Windows.Forms;

namespace DataCollection.Classes
{
public partial class SortpBoundaryImages : Form
{
    public SortpBoundaryImages()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {

    }

    private void pictureBox1_Click(object sender, EventArgs e)
    {

    }
}
}

我不确定我应该看什么,我已经修改了前几天看过的构造函数和继承教程,但是我不确定这是否是问题所在。

2 个答案:

答案 0 :(得分:0)

using System.Windows.Forms;

using DataCollection.Classes;                  // <<<<<<<<<<<<<< Add this line

namespace DataCollection
{
public class Layers
{
    [CommandMethod("CivilData")]

    public static void Main()
    {

        Form sortP = new SortpBoundarImages();
}}}

答案 1 :(得分:0)

using System.Windows.Forms;

namespace DataCollection
{
public class Layers
{
    [CommandMethod("CivilData")]

    public static void Main()
    {

        Form sortP = new Classes.SortpBoundarImages();
}}}