Where are you selecting that option? Describe the steps - menus used, etc.
I'm not using VS2019, but in VS2017 for a C++ WinForms app I would
usually go to the menus:
Project->Add New Item->UI->Windows Form
- Wayne
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Using VS2019 VC++ under Win10 building CppCLR_WinformsProject.
Project Loads and Builds as expected.
I add a button to form1 and test it.... OK
Now when I click the button I'd like to display another form - Form2.
I think the new form should be a new item Thus Add new item seems logical ?
But Form is not shown. I see Code, Formatting , Data and others.
What should I do ?
TIA
Bob
Where are you selecting that option? Describe the steps - menus used, etc.
I'm not using VS2019, but in VS2017 for a C++ WinForms app I would
usually go to the menus:
Project->Add New Item->UI->Windows Form
With Form1.h [Design] visible, I also try
Project | Add New Item and see
Code,Formatting,Data,Resource,Web,Utility,
Property Sheets,Test, HLSL Graphics ,Online
Note that there is no UI->Windows Form
Bob
In the Properties for the project make sure that you have
Common Language Runtime Support (/clr)
selected under
General->Common Language Runtime Support
To add a new form in CppCLR_WinformsProjekt1 VS2019, here is a workaround maybe you can refer to.
First, right click "Headerdateien" and select "Add/New item...".
Click tag "UI", choose "Windows Form" and add it.
Now maybe you will get an error as below.
Just close it and add the following code to the MyForm1.cpp:
using namespace System;
using namespace System::Windows::Forms;
[STAThreadAttribute]
void Main(array<String^>^ args) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
CppCLR_WinformsProjekt1::MyForm1 form;
Application::Run(% form);
}
Then save it and close the Visual Studio, then reopen the Project and build/run it.
You will see the "MyForm1.h" in "Solution Explorer".
Thank you KyleWang
I tried your suggestion but errors resulted in these two lines of code:
CppCLR_WinformsProjekt1::MyForm1 form;
Application::Run(% form);
// -------------------------------Errors follow----------
name followed by :: must be a class ....
expected a ';'
identifier 'form' is undefined
// -----------------------------------