Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C# Screen to screen app

Options
  • 31-01-2009 6:06pm
    #1
    Closed Accounts Posts: 14,762 ✭✭✭✭


    Hi

    I'm working on an application that has a format based on screen to screen, rather than a menu. When the app runs the welcome screen appears, user clicks >> button, brings to options screen,two options,user selects one, another form brought up etc etc... Each screen is a separate form, so my button click event opens the next relevant screen, but doesn't close the last one. I'm very new to c#, so it's probably something really simple, but i can't seem to find an answer anywhere. The code I have in for the >> button on the welcome screen is as follows:

    private void btnNextOptionsPage_Click(object sender, EventArgs e)
    {

    OptionsPage1 optionspage1 = new OptionsPage1();
    DialogResult result = optionspage1.ShowDialog(this);
    Close();
    }

    Could be all wrong, but i found this in a similar application (or something like it) Please please please help...! :confused:

    I've considered using a wizard, as thats the way i want it to work, but don't think thats possible...?
    Thanks in advance


Comments

  • Closed Accounts Posts: 14,762 ✭✭✭✭stupidusername


    I think this can be deleted now,i have found a solution! :D


  • Closed Accounts Posts: 2,349 ✭✭✭nobodythere


    Share, for the sake of people who come across it while googling


  • Closed Accounts Posts: 14,762 ✭✭✭✭stupidusername


    I found a sort of solution on eggheadcafe, that says if you close the main form (in my case the welcome screen) the whole application will shut down, which is kind of what was happening. So i took the close() out of the welcome page and fixed it up so now it looks like this:

    private void btnNextOptionsPage_Click(object sender, EventArgs e)
    {

    OptionsPage1 optionspage1 = new OptionsPage1();
    optionspage1.Show();
    }

    And for every other page, besides the main form, you also add this.Close() under your page.Show()
    It means that you will always have the original screen open behind the current one but sure what can ya do!? I don't think there's a solution to that, but i don't really mind...
    :D yay!


  • Registered Users Posts: 197 ✭✭cracker


    I had a similar post last week on something I was trying. In the end I used an MDI form as the first form and then just displayed every other form as a child of that. That way your application dosn't shut down as the MDI form stays open the whole time. Better than having the welcome screen open in the background I think but still not really what I wanted. I am sure there must be a better way to do this but I haven't figured out how yet.


  • Registered Users Posts: 4,769 ✭✭✭cython


    I'm not sure of the exact syntax (as I haven't looked at C# in a while), but without going down the MDI route, it is possible to simply hide the main form, or first page. Possibly just set the visible attribute to false, or calling a .hide() method. It can be done though

    EDIT: Dug this up from an old app I wrote. Each form should have a hide method (e.g. this.Hide()), so you should be able to use that to make the mainform invisible


  • Advertisement
  • Registered Users Posts: 197 ✭✭cracker


    It just seems to me there should be a way to keep a forms application running while being able to close the form that was instantiated in Main().


  • Registered Users Posts: 4,769 ✭✭✭cython


    cracker wrote: »
    It just seems to me there should be a way to keep a forms application running while being able to close the form that was instantiated in Main().

    Now that you mention it, a thread available at http://bytes.com/groups/net-c/524979-c-form-close-problem makes reference to opening forms in sequence from the application level, which might work here as well


  • Registered Users Posts: 197 ✭✭cracker


    That looks like it might work, as long as there is an option on every form to exit the application or at least return to another form that allows the user to exit the app.


Advertisement