[RESOLVED] " InvalidArgument=Value of '0' is not valid for 'index'" When Selecting 2nd Item
When I select one ListViewItem, the data populates correctly. But after selecting the second, it throws this exception. This exception would normally be thrown if I tried to set the selected item's properties, without have an item selected. But I check this in code. So I can't figure out what's going on.
Code:
private void lvwAttributes_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.lvwUserAttributesMapping.SelectedItems.Count > 0)
{
this.lvwUserAttributesMapping.SelectedItems[0].SubItems[1].Text = this.lvwAttributes.SelectedItems[0].Text;
this.lvwUserAttributesMapping.SelectedItems[0].SubItems[2].Text = this.lvwAttributes.SelectedItems[0].SubItems[1].Text;
}
}
EIDT: I fixed it by checking if the second list view had a selected item.
Re: " InvalidArgument=Value of '0' is not valid for 'index'" When Selecting 2nd Item
Is the item still selected on the line with SubItems[2]