C++/CLIでリッチテキストボックスオブジェクトに文字型変数が追加出来ない。
初歩的な内容で恐縮ですが、現在C++・CLIを勉強中です。
VisualStudio2015を使用しています。
###発生している問題・エラーメッセージ
自動生成されたリッチテキストボックスの中のTextメンバにchar型配列やString型変数を代入したいのですが上手く行きません
Textメンバを指定して、直接文字列を代入する事は出来るのですが、変数の代入が出来ません
エラーメッセージ
これらのオペランドと一致する演算子 "+" はありません
###該当のソースコード
#pragma once
namespace CON_SENSOR {
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> /// MyForm の概要 /// </summary> public ref class MyForm : public System::Windows::Forms::Form { public: MyForm(void) { InitializeComponent(); // //TODO: ここにコンストラクター コードを追加します // } protected: /// <summary> /// 使用中のリソースをすべてクリーンアップします。 /// </summary> ~MyForm() { if (components) { delete components; } } private: System::Windows::Forms::Button^ START; protected: protected: private: System::ComponentModel::BackgroundWorker^ backgroundWorker1; private: System::Windows::Forms::RichTextBox^ Disp_data; private: /// <summary> /// 必要なデザイナー変数です。 /// </summary> System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
/// コード エディターで変更しないでください。
/// </summary>
void InitializeComponent(void)
{
this->START = (gcnew System::Windows::Forms::Button());
this->backgroundWorker1 = (gcnew System::ComponentModel::BackgroundWorker());
this->Disp_data = (gcnew System::Windows::Forms::RichTextBox());
this->SuspendLayout();
//
// START
//
this->START->Location = System::Drawing::Point(97, 379);
this->START->Name = L"START";
this->START->Size = System::Drawing::Size(75, 23);
this->START->TabIndex = 0;
this->START->Text = L"START";
this->START->UseVisualStyleBackColor = true;
this->START->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// Disp_data
//
this->Disp_data->Location = System::Drawing::Point(12, 13);
this->Disp_data->Name = L"Disp_data";
this->Disp_data->Size = System::Drawing::Size(246, 345);
this->Disp_data->TabIndex = 1;
this->Disp_data->Text = L"";
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(8, 15);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(270, 431);
this->Controls->Add(this->Disp_data);
this->Controls->Add(this->START);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { //////問題はここ///// char test[] = "test\n"; this->Disp_data->Text += test; //////////////////// } };
###試したこと
String test = "test\n";
this->Disp_data->Text +=test;
これでもダメですが
this->Disp_data->Text += "test\n";
このように直接文字列を代入するとうまく行きます。
###補足情報(言語/FW/ツール等のバージョンなど)
初歩的な内容で恐縮ですが、詳しい方アドバイス頂けましたら幸いです。

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/11 00:05
2017/01/11 00:09