添加了新表单,但无法在代码中调用/使用它 [英] Added new form, but cannot call/use it in code

查看:118
本文介绍了添加了新表单,但无法在代码中调用/使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中添加了新表单( Form3.cs ) - >添加新表单。



我试着写:

I added new form (Form3.cs) on my project with project --> add new form.

I tried to write:

Form3 f3 = new Form3(); 



并强调 Form3 并收到错误:


and underlines "Form3" and get the error:

The type or namespace Form3.cs could not be found (are you missing a using directive or an assembly reference)? 



我没有删除任何东西。



如何解决这个问题?


I have not deleted anything.

How to fix this?

推荐答案

您好!



我能够通过更改命名空间的名称来复制此类错误消息



Form3 中,您有以下内容: namespace Aprer

Hello!

I was able to replicate this kind of error message by changing the name of the namespace.

In your Form3 you have the following: namespace Aprer
namespace Aprer   // This name must be the same as the namespace in Form1
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Close();
        }
    }

}





这可能是问题所在。 />


检查 Form1 和<$格式的名称空间 c $ c> Form3 ,它们必须相同。



或者你可以输入 Form1 :使用Aprer;



甚至:



This may be the problem.

Check the namespace of the form Form1 and Form3, they must be the same.

Or you can put in Form1: Using Aprer;

Or even:

Aprer.Form3 f3 = new Aper.Form3();
f3.show();


这篇关于添加了新表单,但无法在代码中调用/使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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