-
Senior Member
Two Noobish VS C# 2008 Questions
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:
Code:
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.
MSI 870S-G46 | AMD Phenom II X4 965 @ 3.8ghz | Gigabyte Radeon 7870 Ghz Edition | 1 x 128GB Kingston HyperX SSD | 2 x WD 500GB Blue HDD | Arch Linux x64 | BFG Tech LS SERIES LS-550 550W | 2 x 4GB DDR3 1600 RAM, 2 x 2GB DDR3 1600 RAM (12 GB)
-
Senior Member
I assume you've got the other forms built up?.
In that case you needs to create an instance of your form
Code:
Form1 myForm = new Form1();
myForm.Show(); // or myForm.ShowDialog();
and to close would be
Hope this helps
"I once prayed to god for a bike, but quickly found out he didnt work that way...so I stole a bike and prayed for his forgiveness"
-
Senior Member
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.
MSI 870S-G46 | AMD Phenom II X4 965 @ 3.8ghz | Gigabyte Radeon 7870 Ghz Edition | 1 x 128GB Kingston HyperX SSD | 2 x WD 500GB Blue HDD | Arch Linux x64 | BFG Tech LS SERIES LS-550 550W | 2 x 4GB DDR3 1600 RAM, 2 x 2GB DDR3 1600 RAM (12 GB)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|