I was trying to delete the currently selected listview item using MFC methods, but obviously they werent compatible

How can I accomplish this in VS 2005 (standard .NET windows forms NOT MFC?

I have tried

void CMyListView::DeleteSelectedRow()
{
  int nIndex = GetListCtrl().GetSelectionMark();

  if(nIndex != -1)
  {
    GetListCtrl().DeleteItem(nIndex);
  }
}

Thanks in advance

Recommended Answers

All 2 Replies

That might be what you are looking for

//C++ 2005
	private: void DeleteIt()
	{
	    if (listView1->SelectedItems->Count>0)
  	        listView1->Items->RemoveAt(listView1->SelectedIndices [0]);
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.