Nawar Tabaa

Nawar Tabaa

  • NA
  • 1
  • 0

Accessing & changing controls values from another form

Jan 18 2009 2:02 AM

Hello,

I have two forms, form1 & form2, the second is shown as the following:

//////////////////////
form2 frm2 = new form2;
frm2.ShowDialog();
//////////////////////

On form1 there is a richtextbox which I want to change it's value from form2, so I created a proberty on form1 that get & set the text value:

//////////////////////
public string TextOfRTB
{
get {return this.myrtb.text;}
set {this.myrtb.text = value;}
}
//////////////////////

also I created another property of the second form form2:

//////////////////////
private string strText;
public string TextOfForm1RTB
{
get {return strText;}
set {strText = value;}
}
//////////////////////

and changed the calling function the show the second form form2 to be:


//////////////////////
form2 frm2 = new form2;
frm2.TextOfForm1RTB = TextOfRTB;
frm2.ShowDialog();
//////////////////////

However, when I try to change the text in form1 from form2 by calling

//////////////////////
this.TextOfForm1RTB = "what so ever";
//////////////////////

Nothing takes place on form1, so any helping idea?