C++ CodeDOM 解析器错误 : Line: 75, 列:57 --- 内部错误

标签 c++ windows-forms-designer

我知道这个问题已经被问过(很多次)但我似乎找不到答案。

我已经将一个 TestBox 拖到窗体上,它生成了代码 void InitializeComponent(void) 方法给我。然而,当我添加这一行时:

this->MyTextBox->Text = DateTime::Now.ToString();

打开设计器出现标题错误? 我的问题是,为什么会这样?以及如何摆脱它。

这是页面的完整代码:

#pragma once

namespace Project1 {



    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 MyForm
    /// </summary>
    public ref class MyForm : public System::Windows::Forms::Form
    {
    public:
        MyForm(void)
        {
            InitializeComponent();
            //
            //TODO: Add the constructor code here
            //
        }

    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~MyForm()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::TextBox^  MyTextBox;
    protected: 

    protected: 

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

    #pragma region Windows Form Designer generated code

        //MAIN METHOD FOR FORM

        void InitializeComponent(void)
        {
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->MyTextBox = (gcnew System::Windows::Forms::TextBox());
            this->SuspendLayout();
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(132, 123);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(75, 13);
            this->label1->TabIndex = 0;
            this->label1->Text = L"Callum Holden";
            this->label1->Click += gcnew System::EventHandler(this, &MyForm::label1_Click);
            // 
            // MyTextBox
            // 
            this->MyTextBox->Location = System::Drawing::Point(54, 183);
            this->MyTextBox->Name = L"MyTextBox";
            this->MyTextBox->Size = System::Drawing::Size(100, 20);
            this->MyTextBox->TabIndex = 1;
            this->MyTextBox->Text = L"g" + DateTime::Now.ToString();



            // 
            // MyForm
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(308, 275);
            this->Controls->Add(this->MyTextBox);
            this->Controls->Add(this->label1);
            this->Name = L"MyForm";
            this->Text = L"MyForm";
            this->ResumeLayout(false);
            this->PerformLayout();

        }


#pragma endregion

    private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {

             }
    };
}

感谢您的任何建议!

卡勒姆

最佳答案

试试这个:(找到 here)

this->MyTextBox->Text = DateTime::Now->ToString();

关于C++ CodeDOM 解析器错误 : Line: 75, 列:57 --- 内部错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19096694/

相关文章:

Ubuntu 中的 C++ 手册页

c++ - 对临时对象的常量引用不会延长其生命周期

c# - Visual Studio 设计器 View 无法获得正确的形式

.net - 在设计时隐藏私有(private)子控件属性

c++ - 是否可以在运行时检查 msvcrt.dll 中的 _controlfp_s?

c++ - 在头文件中声明的函数中使用指向结构的指针

c++ - 如何使用 OpenGL 交叉编译 UnixBench?

c# - 无法在设计器 Visual Studio 2015 中打开表单(使用 C#)

c# - Visual Studio Windows 窗体 "Value does not fall within the expected range."

c# - 如何将自定义 IDesigner 移动到同一解决方案中的单独程序集?