Click here to Skip to main content
15,886,776 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
I have two forms, form1 and form2. I first executed form1 . Later I added a new item as form2 and when I tried to execute this form2 it is not getting executed instead form1 only is getting executed. How to run this form2 separately by avoiding form1.
Posted

What you need to do is open Program.cs (I'm assuming that you are using c#).
It should look something like this:
C#
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Music
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //This is the line you need to change
            Application.Run(new Form1());
        }
    }
}


Changing the line I pointed out to
C#
Application.Run(new Form2());

should do the trick.
Hopefully you understand why? :-)
 
Share this answer
 
 
Share this answer
 
Comments
Abhinav S 23-Mar-14 0:48am    
5.
Sergey Alexandrovich Kryukov 23-Mar-14 0:54am    
Thank you, Abhinav.
—SA
Here is a video that might help you - [^].
 
Share this answer
 
Of course you can, See my answer below..

In program.cs, do this,
Application.Run(new Form2());

Simple, huh ?! :)

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900