On Aug 30, 10:00 pm, vbtrying <vbtry...@discussions.microsoft.com>
wrote:
It is an already existing instance. How to I determine the instance? I see
that by using the NEW keyword, it is making a new instance.
If I try using the "frmMain.lblWorkStatus.Text" syntax without creating a
new instance, I dont see the lblWorkStatus control using the . sequence
I'm lost of this one ... thanks for the help !
In child form, define this
public frmMain myParentForm;
While creating the child form, set the parent form.
//Creating child
FrmChild frmChild = new FrmChild();
//Set Parent
frmChild.MyParentForm = this;
Now you can access the mainfrm using
frmChild.myParentFrom.lblWorkStatus.Text
But you wont be able to code it this way, as parent is created in a
different thread. You need to have a method on parent form for
updating the status, and invoke that method from your child form.
Create a method in parent:
public void UpdateStatus(string message)
{
this.lblWorkStatus.Text = message;
}
define a delegate in child form:
private delegate void delegateUpdate(string message);
and for updating the status:
delegateUpdate RelayMessage=new
delegateUpdate(this.myParentFrom.UpdateStatus)
invoke(RelayMessage,new object[] {message});