Share via

After creating a Windows form, nothing happens

Ілля Корнійчук 0 Reputation points
Jul 12, 2023, 12:49 PM

Here's what I do.
These are my settings in VS installer.

User's image

Then i create a project

User's image

Then i add New ItemUser's image

And select windows form

User's image

But after that, nothing is added and nothing happens, so what to do?
User's image

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,924 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,892 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Reza Aghaei 4,981 Reputation points MVP
    Jul 13, 2023, 1:54 PM

    I noticed C++ tag, and the project type as CLR Empty project. In this case, you need to add the entry point to your code, for example, you can follow these steps:

    1. Create an Empty CLR project (C++) (let's say Project1)
    2. Add a new Item, and from CLR templates, choose Windows Form (let's say MyForm)
    3. Open MyForm.cpp and add the following code as entry point to run the form. To do so, paste the following code in the file:
    #include "MyForm.h"
    
    using namespace System;
    using namespace System::Windows::Forms;
    [STAThread]
    
    void main()
    {
        Application::EnableVisualStyles();
        Application::SetCompatibleTextRenderingDefault(false);
        Application::Run(gcnew Project1::MyForm);
    }
    

    Now you can press <kbd>F5</kbd> and see your form running.

    Note: The approach is pretty similar if you use a CLR console application; then it will create the entry point in the ConsoleApplication1.cpp file, and you can modify the entry point like I above.

    C++/CLI More information:

    C# More information:

    If you are working with C#, you may want to take a look at the following links:

    1 person found this answer helpful.

  2. Ілля Корнійчук 0 Reputation points
    Jul 13, 2023, 5:22 PM

    My decision was to install the Visual Studio 2019 version, in which everything works well

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.