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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

631 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