Solved

How to update a child form label.text? when the child form is allready open and you click on the parent form menu?

Posted on 2004-08-27
6
194 Views
Last Modified: 2012-06-21
How to update child form from Parent form when child form is allready open?
How to know wich child forms are open and in that case update them all?
0
Comment
Question by:portilloleopoldo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 3

Accepted Solution

by:
GrumbleBot earned 63 total points
ID: 11917917
Here is one way of doing this.

      Form[] ar = this.MdiChildren;
      for(int i=0; i<ar.Length; i++)
          ar[i].Text = "Hello";
0
 
LVL 3

Expert Comment

by:GrumbleBot
ID: 11917935
if you don't want to update hidden child forms you could also do soumething like this.

if(ar.Visible == true)
     ar[i].Text = "Hello";


hope this helps.
Good luck
0
 
LVL 8

Expert Comment

by:vinhnl
ID: 11926069
I think you should use event to do this
0
 
LVL 8

Assisted Solution

by:vinhnl
vinhnl earned 62 total points
ID: 11926131
In MDIParentForm:

public event EventHandler ChangeTextChildrent;
private void ChangeTextMyChildrent_Click(object sender, System.EventArgs e)
{
     if(ChangeTextChildrent != null)
          ChangeTextChildrent(this,null);
}

when new childrent form:

this.IsMdiContainer = true;
ChildrentForm newform = new ChildrentForm();
newform.IsMdiChild = true;
newform.MdiParent = this;
this.ChangeTextChildrent += new EventHandler(newform.ChildrentForm_ChangeText);
newform.Show();

In ChildrentForm:

public void ChildrentForm_ChangeText(object sender, EventArgs e)
{
    Label1.Text = "Hello";
}

Good Luck,
VINHNL
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to remove duplicate code from my project 5 66
Securing WEBAPI on Azure 2 55
aspx ascx, c# 7 43
C# DateTime Help 6 46
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question