Sunday, December 1, 2013

Listbox.selectedIndex returns value of -1

It's not clear which line you are getting the index out of range, but looking at your code I would guess it might be



clsBooks tempRecord = (clsBooks)mBooks[lstBooks.SelectedIndex - 2];

By subtracting 2 you can end up with an index of -2 or -1 into the mBooks array/collection, which would likely generate the error.




- HomeGrownCoder My posts are kept as simple as possible for easier understanding. In many cases you can probably optimize or spruce up what I present. Have fun coding!


No comments:

Post a Comment