Results 1 to 3 of 3

Thread: [RESOLVED] InvalidArgument=Value of '0' is not valid for 'index'

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Posts
    149

    Resolved [RESOLVED] InvalidArgument=Value of '0' is not valid for 'index'

    After the first selection of item when I'm trying to select another item in ListView I get following error:
    Code:
    InvalidArgument=Value of '0' is not valid for 'index'.
    Parameter name: index
    Here is the code for SelectedIndexChanged event:
    Code:
    private void listViewPrograms_SelectedIndexChanged(object sender, EventArgs e)
            {
                string selecteditem = listViewPrograms.SelectedItems[0].Text;
                if (listViewPrograms.SelectedItems.Count > 0)
                    buttonUninstall.Enabled = true;
            }

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: InvalidArgument=Value of '0' is not valid for 'index'

    Why did you do this:
    string selecteditem = listViewPrograms.SelectedItems[0].Text;

    Before you checked to see if there were items to be selected?

    If the Selected Items Count is 0, then there is no "SelectedItem" to choose (with [0]).
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Posts
    149

    Re: InvalidArgument=Value of '0' is not valid for 'index'

    How didn't I think of this before?
    Thanks, man!

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