Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 732151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:06:31+00:00 2026-05-14T07:06:31+00:00

what is the best way to keep a child control up to date for

  • 0

what is the best way to keep a child control up to date for changes in the parent.

I have a number of child controls hosted inside my parent object and I can think of two ways to send change information to them.

1) wire the child control to an event in the parent and fire that event on a change in the parent

2) keep a list of the children in an array and iterate through the array when the change has happened and invoke a method in the child to handle the new changes.

I hope I describe it okay.

Both work but there is probably a right way to handle this and a wrong way.

EDIT:
below is my code…for event method. I am not happy with how I have wired the child to the parent;any sugestions.

The Parent…

public  class A_Parent       
{

 public delegate void DelUpdateMessage(  string msg );

public event DelUpdateMessage UpdateMessage;
public A_Parent()
{
  a_Child1.prnt = this;
  a_Child2.prnt = this;
  a_Child3.prnt = this;
  a_Child4.prnt = this;
}

private void FireUpdateMessageEvent(  string message)
{
  var handlers = UpdateMessage;

  if (handlers != null)
    handlers(  message );

}
  }

The child…

public  class A_Child        
    {
    A_Parent pnt;
    public A_Parent prnt
    {
     set
       {
        pnt = value;
        pnt.UpdateMessage += new A_Parent.DelUpdateMessage(pnt_UpdateMessage);
        }
     }


void pnt_UpdateMessage(string msg)  {      }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:06:31+00:00Added an answer on May 14, 2026 at 7:06 am

    Your #1 solution is the best bet, as it allows you to change around your implementation without a change in the parent. Since the parent arguably doesn’t care if it has children, the event-based approach is ideal.

    UPDATE

    The reverse-event approach is disingenuous. People are stating that the parents clearly know what children are interested in them, and I simply tend to disagree with that statement. My designs usually have the children dynamically interested in the parent, and the children subscribing to the events is generally the most favorable way of doing so.

    You can find such examples in the .NET model, such as the Page which has events that you can tie into.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best way to keep session state between browser tabs? I have
Is this the best way to keep a simple track of changes to a
What's the best way to keep a collection-object (List in example) in a Key/Value
I have a Map<Float, MyObject> What is the best way to keep the map
What's best way to keep user logged on a PHP-powered site until he closes
I am trying to found it the best way to keep my scripting i.e.
In PHP, what's the best way to copy an array and keep the keys
The best way to explain my problem is by a example. I have a
The best way I can think of to ask this is by example... In
What's the best way to keep state in a bottom bar that sticks to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.