rohith gowda
rohith gowda

Reputation: 11

error:are you missing using directive or a assembly reference?

I'm new to visual c#(window forms). I'm working on a project which consists of three forms. From1 accesses form2 and form3.Form2 worked well and good. But Form3 is giving some problem. I created form3, added three picture boxes to it and accessed from form1. Now if I run the code I'm getting the error

Error 3 'gp.Form1' does not contain a definition for 'label1_Click' and no extension method 'label1_Click' accepting a first argument of type 'gp.Form1' could be found (are you missing a using directive or an assembly reference?)

error is pointed in form1.designer.cs at this line,

this.label1.Click += new System.EventHandler(this.label1_Click);

without form3 no errors. when i add form3 im getting these kind of errors. though form3.designer is existing why its pointing to form1.designer?

namespace gp
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void Form3_Load(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox3_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {

        }
    }
}

and the in form1 im accessing form3 as

Form3 frm3 = new Form3(name);
frm3.Show();

in form2 i got similar problem.i solved it by changing the name of namespace but its not working with form3. Anyone knows the answer let me know.

Upvotes: 0

Views: 2912

Answers (1)

Lord Relix
Lord Relix

Reputation: 942

Add this to Form3 and see if it works:

    private void label1_Click(object sender, EventArgs e)
    {

    }

You double clicked the Label and it added an event for Click, which you probably deleted from code behind at some point

Upvotes: 2

Related Questions