Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
196 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 252 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 248 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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

722 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