C# & VB.NET School Support

Moderators: None (Apply to moderate this forum)
Number of threads: 135
Number of posts: 228

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
question in c# Posted by amr_007 on 22 Feb 2010 at 8:43 PM
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

Report
Re: question in c# Posted by masterakos on 13 Nov 2011 at 11:16 PM
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.



 

Recent Jobs