change label text of parent form from child form

.net, c#

Solution

when calling the child form, set the `Parent` property of child form object like this..

Test1Form test1 = new Test1Form();
test1.Show(this);

On your parent form, make the property of your label text like as..

public string LabelText
{
  get
  {
    return  Label1.Text;
  }
  set
  {
    Label1.Text = value;
  }
}

From your child form you can get the label text like that..

((Form1)this.Owner).LabelText = "Your Text";

Problem

Possible Duplicate: accessing controls on parentform from childform I have parent form form1 and child form test1 i want to change label text of parent form from child form in my parent form i have method to showresult() `public void ShowResult() { label1.Text="hello"; }` I want to change `label.Text="Bye";` form my child form test1 on button click event. Please give any suggestions.

Original source

Related problems