what is cause of error;
{
private Form2 testc;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
button1.Visible = true;
button2.Visible = true;
button3.Visible = false;
button4.Visible = true;
}
private void button4_Click(object sender, EventArgs e)
{
button1.Visible = true;
button2.Visible = true;
button3.Visible = true;
button4.Visible = true;
}
public void button2_Click(object sender, EventArgs e)
{
button1.PerformClick();
}
public void pictureBox2_Click(object sender, EventArgs e)
{
button1.Visible = false;
button2.Visible = false;
button3.Visible = false;
button4.Visible = true;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
pictureBox2_Click(this, null);
testc = new Form2() ;
testc.Show();
}
}
I want active on button has picture box from form 1 using form 2 that all i need , but i face off problem .
Severity Code Description Project File Line Suppression State
Error CS0120 An object reference is required for the non-static field, method, or property 'Form1.pictureBox2_Click(object, EventArgs)' WindowsFormsApplication7
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private Form1 test;
private void button5_Click(object sender, EventArgs e)
{
Form1.pictureBox2_Click(this, null);
}
}
IF I change a code like this , in Main Project(not for testing)
private void button1_Click(object sender, EventArgs e)
{
test = new MainForm();
test.Refill_sy_Click(this, null);
test.Show();
give this error enter image description here