//flex table opened by JP

Click to See Complete Forum and Search --> : Two Noobish VS C# 2008 Questions


rockinup1231
01-14-2009, 09:25 PM
First off, my apologies in advance if my explanations are confusing because I'm completely new to programming (cept for a little experience with C and now, a tiny bit with C#).

Basically, here's my scenario:

If I want to have multiple Window Forms, how would I make it so, if one clicked a button on the main window, it opens one of the others? An example would be nice.

Also, I want to put an "OK" button on these other Window Forms (they're just messages with labels on them) that will close the window. Now, I know how to close the application by doing something like this:

private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}

But if I use that it would close the entire application and not just the one window.

I've still got alot to learn, and I haven't the faintest idea of how to accomplish these things.

I'm using Visual C# Express 2008 SP1.

Thanks in advance. :t

Tony2005
04-14-2009, 05:56 PM
I assume you've got the other forms built up?.

In that case you needs to create an instance of your form


Form1 myForm = new Form1();
myForm.Show(); // or myForm.ShowDialog();


and to close would be


this.Close();


Hope this helps

rockinup1231
04-17-2009, 06:52 PM
Wow, thought I'd never get an answer, but thanks for the response.

And yes, that does help. I couldn't quite get Show() to work right but that clears up my mistake.

Thanks. :)