且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从子窗体更改父窗体的标签文本

更新时间:2023-12-06 09:27:28

在调用子表单时,请像这样设置子表单对象的 Parent 属性.

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";