如何在表单类外部的richTextBox中输入文本?
我的项目中有四个文件: Form1.h Form1.cpp Main.cpp的 Importfile.cpp
在form1.cpp中我使用函数:
System::Void Form1::SendText_Click(System::Object^ sender, System::EventArgs^ e)
{
info_function();
}
在Importfile.cpp中我试图使用以下代码编写文本:
#include "Form1.h"
#include "Importfile.h"
using namespace Forms_test; // the namespace where my Form class is in
void info_function()
{
//Form1->richTextBox1.AppendText("Starting slaveinfo\n");
//formpointer->richTextBox1->AppendText("Starting slaveinfo\n");
//richTextBox1->AppendText("Starting slaveinfo\n");
// I tried all three.
}
在我的主文件中,我开始这样的表格:
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Form1^ formpointer = (gcnew Form1());
Application::Run(formpointer);
我这样做,所以我可以使用formpointer以某种方式访问我的richtextbox。
我的问题是,当我尝试构建时,我收到错误:“left of' - > AppendText'必须指向class / struct / union / generic类型”
我在想它不知道怎么找不到我的richTextBox指针,但我怎么能确定它呢?我知道可能有更多的问题有点像这样但不知何故我似乎无法找到它们。
先谢谢。