私はこの質問が以前に(何度も)尋ねられたことを知っていますが、答えが見つからないようです.
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) {
}
};
}
提案をありがとう!,
カルム