WFA:如何在复选框列表框中<vector>添加字段

WFA: How to add field in checkedListBox from <vector>

本文关键字:vector lt gt 字段 添加 列表 复选框 WFA      更新时间:2023-10-16

我写了以下代码:

this->checkedListBox1->Items->Insert(0, "Copenhagen");
MyClass * tmp = new MyClasss();
std::vector <Element> AA = tmp->getAllEl();
Element mm = AA.front();
this->checkedListBox1->Items->Insert(1, mm.name);

但是它告诉我:

cannot convert parameter 2 from 'std::string' to 'System::Object ^'

如何将std::string转换为System::Object ^ ?或者我如何在checkedListBox中插入项目?

你应该把你的std::string转换成System::String^,然后通过System::String^,它将是可接受的。

这是如何从std::string创建System::String ^:

String ^ S = gcnew String(mm.name.c_str());

然后传递:

this->checkedListBox1->Items->Insert(1,S);