Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

question in c#

[size=3]hello everyone,
i am new here and i am also a new programmer and i am learning c#..i am using visual studio 2008 and started to build some very simple windows form apllication and now i am facing a problem.
how can i open a new form to replace the old form in a way such that when i close the second form ..all of the application gets terminated..something like the installation wizard of a program or a game..when you hit the next button the window form changes completely and whenver i press the (x)button on top right the installation wizard terminates completelly..i hope someone helps me as i really need to learn that so i can keep going

i hope i can find the help i need here..thanks all in advance[/size]

Comments

  • masterakosmasterakos Posts: 7Member
    Hello to you too.

    Wherever you want to close the application you can add code like: application.exit();

    Now if you want to do this by closing a specific form you have to add in form's close event [application.exit();].

    About the old and new form : All forms are objects.When you create a project visual studio creates a form for you. Now if you want to make another and use it as "main" on your application you have to change the code in program.cs .

    In the Program.cs class there would be Main function something like below

    static void Main()
    {
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
    }

    Change the Application.Run(new Form1());

    to

    Application.Run(new Form2());


    This should work.
    If you need any example in code just let me know.
Sign In or Register to comment.