Re: arguement out of range
If the index 0 is out of range then there is no item at index 0, i.e. there are no items in the collection.
Let me guess: lstConnectionData is a ListView, right? When you change the selection in a ListView the SelectedIndexChanged event is raised twice: once as the old item is deselected and once as the new item is selected. The first time there is no item selected so you have to ignore it, which would require an If statement that tests that there is at least one item selected.
Re: arguement out of range
there are items in the collection and it would be the second part of your post as it does work the first time. Just not if I select another item. I want to populate a textbox each time a new listviewitem is selected. How can I do that then?
Re: arguement out of range
You seem to have simply ignored what I said and stuck to what you assume is the case. First up, there can't possibly be items in the collection if index 0 is out of range. We're talking about the SelectedItems collection here, not the Items collection. Secondly, I've already told you what to do. If you just do it it will work. Add an If statement that tests the number of items in the collection, i.e. its Count property, and only try to access the first item IF there are items present.