I have some form with a menu, when I'm pressing "new" button I want to show another form. (not a child form!)
I have two forms: frmMain and frmSecond
How to show the frmSecond?
I have some form with a menu, when I'm pressing "new" button I want to show another form. (not a child form!)
I have two forms: frmMain and frmSecond
How to show the frmSecond?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
AlanPosted May 11, 2008, 2:27 PM
In frmMain, add this method to receive the string:
internal void ReceiveString(string s)
{
// put code in here to save and/or display the string somewhere, for example
textBox1.Text = s;
}
In frmSecond, add this code to transmit the string (.NET 2.0 or later assumed):
frmMain main = (frmMain)Application.OpenForms["frmMain"];
main.ReceiveString(someString);
JPosted May 11, 2008, 8:44 AM
JPosted May 6, 2008, 7:26 AM
Great!
Thank you
AlanPosted May 6, 2008, 4:27 AM
Try:
frmSecond f2 = new frmSecond();
f2.Show();
If you want frmSecond to maintain input focus until it is closed, use ShowDialog() instead of Show().