0
votes

I'm working on a windows forms projects in microsoft visual studio and when I autogenerated the windows form code there were errors everywhere.

I've put everything with an error in stars (it wouldn't let me do italics etc.)

namespace FormsTest {

using namespace *System*;
using namespace *System*::ComponentModel;
using namespace *System*::Collections;
using namespace *System*::Windows::Forms;
using namespace *System*::Data;
using namespace *System*::Drawing;

/// <summary>
/// Summary for MainDisplay
/// </summary>
*public* ref class MainDisplay : public System::Windows::Forms::Form
{
public:
    MainDisplay(void)
    {
        InitializeComponent();
        initialiseDatabase();
    }

protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~MainDisplay()
    {
        if (components)
        {
            delete components;
        }
    }
private: System::Windows::Forms::PictureBox^  pictureBox1;
protected:


private:
    /// <summary>
    /// Required designer variable.
    /// </summary>
    System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
        this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
        this->SuspendLayout();
        // 
        // pictureBox1
        // 
        *this*->pictureBox1->Location = System::Drawing::Point(12, 74);
        *this*->pictureBox1->Name = L"pictureBox1";
        *this*->pictureBox1->Size = System::Drawing::Size(960, 355);
        *this*->pictureBox1->TabIndex = 0;
        *this*->pictureBox1->TabStop = false;
        // 
        // MainDisplay
        // 
        *this*->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
        *this*->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        *this*->ClientSize = System::Drawing::Size(984, 461);
        *this*->Controls->Add(this->pictureBox1);
        *this*->Name = L"MainDisplay";
        *this*->Text = L"MainDisplay";
        *this*->Load += gcnew System::EventHandler(this, &MainDisplay::MainDisplay_Load);
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
        this->ResumeLayout(false);

    }

It is saying that the "System" must be a namespace name

This is the first time that I've used windows forms I've mostly just used the console.

Thanks for any help you can offer.

1
Remove the public from System::Windows::Forms::Form and I think it is only System::Windows::Forms - DJ Burb
Um that hasn't worked. I made this using the empty project, could that be it if so how can i fix that? - Cjen1
Do you still get the same error when you tried it? Or is the error different? - DJ Burb
I'm getting the same errors. It is where all the stars are in the code that i'm getting the namespace errors - Cjen1
VS2013 no longer has the project template to create a Winforms app. That makes it easy to make small mistakes that produce big problems, like forgetting to compile with /clr in effect. - Hans Passant

1 Answers

2
votes

Ok I have a workaround thanks to Hans Passant. I needed to start the project from a clr empty project, even though VS2013 had said that it had converted it, so that it will compile with clr. I'm no longer getting all the errors.

So thanks again.