John Beeman

John Beeman

  • NA
  • 15
  • 0

How to change a label on Form1 from Form2?

Jul 25 2008 3:30 PM
I am having trouble changing a label on a different form. Can anyone tell me what I'm doing wrong here? Thanks.

On Form 1, I have the following, where label1 is defined in Form1.Designer:

public string Lbl
        {     
            get {
                return label1.Text;
            }
            set {
                label1.Text = value;
                MessageBox.Show(label1.Text); //Debug: Value here shows correctly but label does not actually change on Form
            }
        }



On Form2 I have this:

        void setLabelInForm1()
        {
            Form1 frm1 = new Form1();
            frm1.Lbl = "LOADED";
        }

private void button1_Click_1(object sender, EventArgs e)
        {
                ........................
                setLabelInForm1();
                .......................
        }


Answers (3)