Sorry, I'm a C# beginner
I am trying to make a button on Form 4 that will make change a property of an object in Form 3.
This case, every time I press button 1 on Form 4, the label on Form 3 will say that "You pressed button 1", Same thing on the button 2.
I added this on Form 4.
public partial class Form4 : Form
{
public bool buttonchecked;
private void button1_Click_1(object sender, EventArgs e)
{
buttonchecked = true;
}
private void button2_Click_1(object sender, EventArgs e)
{
buttonchecked = false;
}
And this is what i put on Form 3:
public void label2_Click(object sender, EventArgs e)
{
Form4 form4 = new Form4(); //add
if (form4.buttonchecked == true)
{
label2.Text = "You pressed button 1";
}
else
{
label2.Text = "You pressed button2";
My label2 text is always set to "You pressed button2" but I didn't
I added a code that closes the current form and Opens the other form, maybe this is causing the problem?
this is from the Form 3
this.Hide();
Form4 f4 = new Form4();
f4.ShowDialog();
and this is from the Form 4
this.Hide();
Form3 frm3 = new Form3();
frm3.ShowDialog();
Is there anything something I'm doing wrong?