I have a ListView populated with colors one can choose to customize the UI a bit. I want the user to be able to click an item in the ListView and have it's BackColor become the BackColor of a picturebox (the "preview"). This is my code:
VB.NET Code:
  1. Private Sub listColors_ItemSelectionChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles listColors.ItemSelectionChanged
  2.         clrPreview.BackColor = listColors.FocusedItem.BackColor
  3.     End Sub
If I try to select a different item with one already selected, I get "System.NullReferenceException was unhandled." How can I fix this?