在form中追加文本
C++ : Appending text in form
我已经离开c++有一段时间了,这可能只是我的愚蠢,但为什么这会给我一个错误(代码下面的错误)
代码:
// NetworkServer.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
#include <winsock2.h>
#include <iostream>
using namespace std;
using namespace NetworkServer;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
public void setUsers()
{
string connectedUsers[] = {"John", "Alex", "Phillip", "Steve"};
Form1->txt_connectedClients.AppendText(connectedUsers[1]);
}
return 0;
}
错误:
1>NetworkServer.cpp(22): error C2143: syntax error : missing ';' before '->'
1>NetworkServer.cpp(22): error C2143: syntax error : missing ';' before '->'
Form1是类型名称,需要对象。我看不到代码的上下文,但只要这段代码是在Form1类的方法中编写的,那么这个->将工作。
public ref class Form1 : public System::Windows::Forms::Form
{
//...
public:
void setUsers() {
array<String^>^ connectedUsers = gcnew array<String^> {"John", "Alex", "Phillip", "Steve"};
this->txt_connectedClients->AppendText(connectedUsers[1]);
}
};
注意你是在用c++/CLI语言编程,而不是c++。
txt_connectedClients不存在或不是一个指针。
相关文章:
- 文本文件中的单词链表
- 从命令行c++发送文本文件名
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 2D数组来自文本输入,中间有空格
- 如何将内容数组写入文本文件?
- 无法通过空白将文本文件行分隔为矢量
- 我正在使用嵌套的while循环来解析具有多行的文本文件,但由于某种原因,它只通过第一行,我不知道为什么
- C++将文本文件中的数据读取到结构数组中
- 在指针的帮助下,文本文件中单词的频率
- C++ - 将文本追加到仅具有 NTFS"追加数据"权限的文件
- 外壳追加重定向替换现有文本
- 追加到文本文件在循环中无法正常工作
- 在文本文件中覆盖和追加行(C++)
- 如何将文本追加到文本框
- 将文本文件的内容追加到C++中的另一个文件
- C++ 在追加 Windows API 的特定位置插入文本
- C++ 不追加到文本文件
- 用于将后缀追加到无符号长文本的宏
- 读取显示到控制台的文本文件,然后追加文本文件
- 在form中追加文本