Results 1 to 2 of 2

Thread: [RESOLVED] " InvalidArgument=Value of '0' is not valid for 'index'" When Selecting 2nd Item

Threaded View

  1. #1

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Resolved [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.
    Last edited by weirddemon; Nov 30th, 2012 at 03:23 PM.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width