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:
If I try to select a different item with one already selected, I get "System.NullReferenceException was unhandled." How can I fix this?VB.NET Code:
Private Sub listColors_ItemSelectionChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles listColors.ItemSelectionChanged clrPreview.BackColor = listColors.FocusedItem.BackColor End Sub




Reply With Quote