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
192 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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