Or, get text from a textbox or label from parent form under conditions.
Ok, declared this on parent form...
public bool isFoward = false;And, in the button click event....
isFoward =
true;compose newMsg =
new compose();newMsg.Show();
So, when I read isFoward from the parent form in the load event from compose form.....
if(frmMail.isFoward) this.txtMessage.Text = "test";But, isFoward is always false
I even tried to create a hidden label to read but is always an empty string.
I can read textbox contents though from parent form.
Suggestions
Thanks,
Zath

Send text to another form
Ricky Kelley
In order to have multiple forms like you’ve got be able to read and write values to/from each other, they need to be aware that the other exists and have a reference to them... in your example, how does your new Form (newMsg) know about the form it was created by
Given what you’ve said above, I’m surprised that the following code even works when being run from the load event of the compose form:
if(frmMail.isFoward)
this.txtMessage.Text = "test";
At this point, does it know that frmMail even exists Where is it being populated
My suggestion would be to add a new constructor for your compose form, one that takes a reference to the parent form in and sets it to your frmMail ala:
MainForm myParent;
public compose(MainForm frmMain)
{
this.myParent = frmMain;
}
And then when you do your check later, you would fire the following:
if(myParent != null && myParent.isFoward)
this.txtMessage.Text = "test";
This way we check to see if we’ve set the reference to the parent form, and only if we have we check to see if its isForward flag has been set.
LockyBoy1
Well, mail is the main form which launches when the app begins.
And, on that main form I have....
static compose frmCompose= new compose();which I call in the button click event.
and, on the compose form, I have...
static mail frmMail= new mail();Which I access in the load event to test the isFoward value.
I'll try to change some things around the way you suggested and see if it works better.
Zath
David Walp - Microsoft
Well, couldn't get it to work your way, but got it to work another way.
I place the boolean on the child form and before it opened, set it to true.
Worked fine that way.
Zath