Results 1 to 3 of 3

Thread: Two Noobish VS C# 2008 Questions

  1. #1
    Senior Member rockinup1231's Avatar
    Join Date
    May 2006
    Location
    Northern Michigan
    Posts
    942

    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)

  2. #2
    Senior Member Tony2005's Avatar
    Join Date
    Dec 2002
    Location
    Hartlepool, NE
    Posts
    713
    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

    Code:
    this.Close();
    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"

  3. #3
    Senior Member rockinup1231's Avatar
    Join Date
    May 2006
    Location
    Northern Michigan
    Posts
    942
    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
  •