Add a Form to a Project

srfpala 111 Reputation points
2020-12-20T00:51:44.893+00:00

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

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,903 questions
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. srfpala 111 Reputation points
    2020-12-22T02:49:24.993+00:00

    // Below is the code in MyForm1.cpp but ignore the red underscores.

    include "pch.h"

    include "MyForm1.h"

    using namespace System;
    using namespace System::Windows::Forms;
    [STAThreadAttribute]
    void Main(array<String^>^ args) {
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);
    // The next two lines generate 7 errors
    CppCLR_WinformsProjekt1::MyForm1 form;
    Application::Run(% form);
    }
    Want me to send a screenshot ?


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.