I'm pretty sure that the selectedRow can be -1 if not clicking on an item? Are you sure this update is correct?