I have a listview component with the following simple items:

Name       Size   Fixed Lens
-------------------------------
camera1    35mm   Yes
camera2    16mm   No

I'm using C# and want to edit various items but the following code give me value '2' is not valid for index:

listView1.SelectedItems[0].SubItems[2].Text = "Test";

What am I doing wrong?

Thanks...

Certain parts of the listview have always been kind of kludgy.
You'll probably have more success using then FocusedItem property instead:

listView1.FocusedItem.SubItems[2].Text = "test";
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.