我想声明一个托管数组,因为我需要在ListView上进行搜索,但是这个声明是错误的,我得到了这些错误:
array<ListViewItem^, 128> searchedItems = gcnew array<ListViewItem^>;
E0070 incomplete type is not allowed
E0079 expected a type specifier
我需要它从这里工作,这是一个按钮单击事件从主窗体:
private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {
String^ searchString = tbDenominazione->Text;
array<ListViewItem^>^ itemsSearched = gcnew array<ListViewItem^>^(listViewMain->Items->Count);
int i = 0;
int matches = 0;
for (; i < listViewMain->Items->Count; i++) {
ListViewItem^ currentItem = listViewMain->Items[i];
// String^ currentItemText = currentItem->Text;
// cout << msclr::interop::marshal_as<std::string>(currentItem->SubItems[1]->ToString());
if (currentItem->SubItems[1]->Text->Contains(searchString)) {
matches++;
}
}
cout << "Corrispondenze trovate: " << matches << endl;
}
1条答案
按热度按时间sf6xfgos1#
我解决了指定这个