سؤال

Code

I'm trying to write Column 1 + Column 2 for every row but I keep getting:

Error

I actually had it working at one point, but I re-opened the project and now it doesn't. Any idea as to what's happening?

هل كانت مفيدة؟

المحلول

the discription of listitem.clear:Removes all items and columns from the control. http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.clear(v=vs.110).aspx

Since the are no items in the listview you cannot retieve the first one(listview1.items[0])

نصائح أخرى

You trying to access an array where the there is no data. You can surround it with a try catch also to avoid crash. or test there is data with an if clause

if(listview1.Items[0].subItems[1]!=null)
  sr.write(...);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top