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 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.

Training for .Net Developers

SPONSORED BY

JetBrains ReSharper Ultimate
.NET code analysis, refactorings, navigation, unit testing, code coverage and profiling in Visual Studio, a bonus for C++ devs, bundled at 50% off.