views:

261

answers:

1

Hi, I am facing some prob in managed C++, I can fill my ListView , but I am unable to edit specific row at later time

I can fill like

listView1->View = View::Details;   
listView1->Columns->Add("S.no",......
ListViewItem^ itmp = gcnew System::Windows::Forms::ListViewItem("100");
ListViewSubItem^ itms1 = gcnew ListViewSubItem(itmp, "12:12:12 PM");
itmp->SubItems->Add(itms1);
listView1->Items->Add(itmp);

I want to implement following VB code in managed C++ , but showing errors

Dim FindlvItem() As ListViewItem  // here i am facing problem in conversion to c++ managed
FindlvItem = Me.ListView1.Items.Find("100", False)
FindlvItem(0).SubItems(0).Text = "01:01:01 AM"

I dont want to use foreach loop to save processing

vs.net 2008

A: 

You should be able to convert the code almost line for line to C++/CLI. The only problem is that Find will return a collection of list view items, not just a single item.

array<ListViewItem^>^ FindlvItem = ListView1->Items->Find("100",false);
if (FindlvItem->Length == 1)
{
    FindlvItem[0]->SubItems[0]->Text = "01:01:01 AM";
} // if found
pcdejager