I'm having trouble with updating a specific field of an ListView.
I need to update SubItem 'Value' at Column 'Product.Text' and row 2.
I tryed this code:
lvMain.Items[Product.Text].SubItems.Text = Value;but its giving me this error:
Object reference not set to an instance of an object.
Is there another method to update a specific column and row of a ListView?Friday, September 14, 2012 6:51 PM
Usually the access to item is not with [Product.Text] (as it is a string), but with an index. Read this:
There is an example there: listView1.ListItems[i].SubItems.ToString());
Anyway, Bing for "c# listview" for example that will show you some more tips.
You mention that the error message is "obj reference not set". This is caused by using something that has not been declared. It could be that you don't have yet SubItem as this is not available in code time, but only in run-time.
You need to learn a bit more of debugging stuff in run-time, as setting breakpoints and inspect objects and variables, like setting a breakpoint there and "add watch" of your objects, like the lvMain and check for items there.
Adelino AraujoSaturday, September 15, 2012 11:40 AM