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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
C# Export DataGridView 4 41
Problem to open Excel file 15 44
getting id from database 5 24
Calling stored proc in EDMX 11 19
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now