Forum guidelines
  • Home
  • »
  • C# Language
  • »
  • How to update parent form when changes made to the child form.
AuthorQuestion
How to update parent form when changes made to the child form.
Posted 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 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 on: 24 Dec 2009  
Re: How to update parent form when changes made to the child form.
Posted on: 30 Dec 2009  
How to pass Parent Form as owner.

SPONSORED BY

Offshore Software and Database Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.