Forum guidelines
AuthorQuestion
minakshi
How to update parent form when changes made to the child form.
Posted By minakshi on 24 Dec 2009
Hello,
I want to update parent form when changes are made to the child form. Can somebody help me out in this regard.
Minakshi

AuthorReply
Lalit M
  • 0
  • 0
accepted
Re: How to update parent form when changes made to the child form.
Posted By Lalit M on 24 Dec 2009   Accepted Answer
You will need to provide a property in the parent form that can change the label.
for e.g.

public class ParentForm: System.Windows.Forms.Form
      {
            private System.Windows.Forms.Label
label1;

            public string LabelValue
            {
                  get
                  {
                        return this.label1.Text;
                  }
                  set
                  {
                        .label1.Text= value;
                  }
            }
      }

then from the child form:

if (this.Owner is ParentForm)
{
      ((ParentForm)this.Owner).LabelValue = @"Some label value";
}

when you show the child form, you pass the ParentForm as the owner.

Please check my answer if you help.....

Thanks ....Lalit.

Re: How to update parent form when changes made to the child form.
Posted By Hiren Soni on 24 Dec 2009  
Re: How to update parent form when changes made to the child form.
Posted By minakshi on 30 Dec 2009  
How to pass Parent Form as owner.

C# Corner Annual Conference 2016

SPONSORED BY

Spire.Doc - Free .NET Word API
Use Spire.Doc to create, read, write, print, and convert word documents to OpenXML, RTF, TXT, XPS, EPUB, EMF, HTML, Image and PDF.