我正在使用microsoft visual studio中的Windows窗体项目,当我自动生成windows窗体代码时,到处都有错误。
我把所有内容都放在了星星的错误中(它不会让我做斜体等)。
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);
}
这就是&#34;系统&#34;必须是命名空间名称
这是我第一次使用Windows表单,我主要使用的是控制台。
感谢您提供的任何帮助。
答案 0 :(得分:2)
好的,我有一个解决方法感谢Hans Passant。我需要从clr空项目启动项目,即使VS2013已经说它已经转换它,所以它将使用clr进行编译。我不再收到所有错误。
再次感谢。