【急】关于error C2227: left of '->Text' must point to class/struct/union/generic type

ariesjh0411 2010-05-10 02:29:10
Form1.h 的内容
#pragma once
void show();

namespace csdn {

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

public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}

protected:
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Button^ show;
protected:

private:
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->show = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(12, 12);
this->textBox1->Multiline = true;
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(268, 195);
this->textBox1->TabIndex = 0;
//
// show
//
this->show->Location = System::Drawing::Point(100, 231);
this->show->Name = L"show";
this->show->Size = System::Drawing::Size(75, 23);
this->show->TabIndex = 1;
this->show->Text = L"show";
this->show->UseVisualStyleBackColor = true;
this->show->Click += gcnew System::EventHandler(this, &Form1::show_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 266);
this->Controls->Add(this->show);
this->Controls->Add(this->textBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void show_Click(System::Object^ sender, System::EventArgs^ e) {
show();
}
};
}



csdn.cpp 的内容


#include "stdafx.h"
#include "Form1.h"

using namespace csdn;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);

Application::Run(gcnew Form1());
return 0;
}

void show(){
csdn::Form1::textBox1->Text=("Hello World\r\n");
}


错误 如下:
error C2227: left of '->Text' must point to class/struct/union/generic type

我想在cpp中更新textbox1的内容 如何做到呢? 求解
在线等~


...全文
1062 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bo453669907 2010-08-02
  • 打赏
  • 举报
回复
left of '->Text' must point to class/struct/union/generic type
把 ->Text 改成 .Text 试试。
成功率 30%
APP开发王 2010-06-10
  • 打赏
  • 举报
回复

友情帮顶下!顺便学习学习!
ariesjh0411 2010-05-10
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zenny_chen 的回复:]
我靠,居然把恶心的托管C++也拿出来啦。
csdn::Form1可能需要先创建一个对象吧。
莫非是csdn::Form1(). textBox1->Text??
呵呵呵。
[/Quote]
error 没有了 但是不能显示内容
而且我还要修改textbox1的声明 为public
zenny_chen 2010-05-10
  • 打赏
  • 举报
回复
我靠,居然把恶心的托管C++也拿出来啦。
csdn::Form1可能需要先创建一个对象吧。
莫非是csdn::Form1(). textBox1->Text??
呵呵呵。

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧