我使用以下内容清除整个 listView
void Form1::button2_Click(System::Object^ sender, System::EventArgs^ e)
{
ActiveControl = tabControl1->SelectedTab;
if (listView3->Items->Count == 0)
{
::MessageBox(0, "Please select data.", "Failed to clear data.", MB_OK | MB_ICONERROR);
}
else
{
listView3->Items->Clear();
}
}
然后我尝试使用以下内容清除所选项目...但它崩溃了...
void Form1::listView3_ItemCheck(System::Object^ sender, System::Windows::Forms::ItemCheckEventArgs^ e)
{
listView3->Items[e->Index]->Remove();
}
我会用什么替换我的删除功能,这样它就不会崩溃?
编辑:这就是我添加到我的 listView3 的方式...
ListViewItem^ subitem = gcnew ListViewItem();
subitem->SubItems->Add(textBox2->Text);
listView3->Items->Add(subitem);