dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Unable to open new form

  1. #1
    Join Date
    Jul 2012
    Posts
    9

    Unable to open new form

    Hi,

    I have been programming in Java for a few years and am now trying to teach myself C#. I am using Visual Studio 2010 as my IDE.

    I have created a basic form called AddVideo, and I have a separate file called Program.cs
    I want Program.cs to display an instance of the AddVideo form.
    So far I have tried to do:
    Code:
    AddVideo form = new AddVideo();
    But when I run Program.cs, it displays the program for less than a second and then exits.

    How can I fix this?

    Thanks

  2. #2
    Join Date
    May 2002
    Location
    Boston
    Posts
    67

    Cool Re: Unable to open new form

    Try

    Code:
        
    static class Program
        {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new AddVideo());
            }
        }

  3. #3
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Unable to open new form

    An IDE could help you avoid this sort of syntactical forgetfulness. I strongly recommend SharpDevelop since it is free, open-source.
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  4. #4
    Join Date
    Jul 2012
    Posts
    9

    Re: Unable to open new form

    Quote Originally Posted by curt_c View Post
    Try

    Code:
        
    static class Program
        {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new AddVideo());
            }
        }
    Thanks :-)

  5. #5
    Join Date
    Jul 2012
    Posts
    9

    Re: Unable to open new form

    Quote Originally Posted by BioPhysEngr View Post
    An IDE could help you avoid this sort of syntactical forgetfulness. I strongly recommend SharpDevelop since it is free, open-source.
    I am using an IDE, Visual Studio 2010.

  6. #6
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Unable to open new form

    Oh, well then use it to generate a WinForms project. :-)
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)