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:
- Create an Empty CLR project (C++) (let's say Project1)
- Add a new Item, and from CLR templates, choose Windows Form (let's say MyForm)
- 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:
- .NET (6, 7): Tutorial: Create a Windows Forms app with .NET.
- .NET Framework (4.X): Create a Windows Forms app in Visual Studio with C#