Joko Susilo

Joko Susilo

  • NA
  • 5
  • 2.1k

update label from other windows form

Jul 21 2010 3:11 AM
i make a simple test program that if i press button in the form1, it will change label text in Main Form.
here a code :
In MainForm.cs

void MainShown(object sender, EventArgs e)
        {
            Form1 frm =new Form1();
            frm.ShowDialog();
        }
public string Lbl
{
    get{
         return label1.Text;
    }
    set{
        label1.Text = value;
    }
}


code from Form1.cs :
void Button1Click(object sender, EventArgs e)
{
    Main main = new Main();
    main.Lbl = "UPDATE DONE!!";
    main.label1.Refresh();
    this.Close();
}


I press button1 and never change the text! please help me...

tks.




Answers (5)