Results 1 to 2 of 2

Thread: [2005] listview selected index

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2006
    Posts
    719

    [2005] listview selected index

    how to change the selected index of a listview's subitems(1)?

    Because this code doesnt work;

    Code:
    Listview1.Items(Listview1.SelectedItems(0).Index).SubItems(1).Text = "HELLO"
    error is:
    InvalidArgument=Value of '1' is not valid for 'index'
    Parameter name: index

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] listview selected index

    Haven't we been through this before? Do NOT, I repeat NOT, do this:
    vb.net Code:
    1. Listview1.Items(Listview1.SelectedItems(0).Index)
    when this gives EXACTLY the same result:
    vb.net Code:
    1. Listview1.SelectedItems(0)
    As for your question, if you haven't added any subitems to the item in the first place then you can't set their Text properties. Something that doesn't exist doesn't have any Text property.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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