Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ArgumentOutofRangeException was unhandled in visual studio 2008

Posted on 2010-09-21
5
Medium Priority
?
494 Views
Last Modified: 2012-05-10
Hello,
I'm getting this error when trying this code below
InvalidArgument=Value of '1' is not valid for 'index'. Parameter name: index



Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
               Me.txt_Owner.Text = ListView1.SelectedItems(0).Text
            Me.txt_Component.Text = ListView1.SelectedItems(1).Text


    End Sub

Please assist.
0
Comment
Question by:angel7170
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33726598
you are trying to pass listview item to a textbox?
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33726638
try this

Dim str As string 'or integer

        For Each sItem As ListViewItem In lvList.SelectedItems
           
          str = sItem.Text 'this gives you the text of the first column 
'or
          str = sItem.SubItems(2).Text 'this gives you the text of the third column 
        Next

Open in new window

0
 
LVL 18

Accepted Solution

by:
John (Yiannis) Toutountzoglou earned 2000 total points
ID: 33726755
try my code in Listview Click or double click event
0
 

Author Comment

by:angel7170
ID: 33726853
This code worked with slight modifications when in listview click

For Each sItem As ListViewItem In ListView1.SelectedItems

            Me.txt_Owner.Text = sItem.Text 'this gives you the text of the first column
            'or
            Me.txt_Component.Text = sItem.SubItems(1).Text 'this gives you the text of the third column
        Next

Thanks as always. your help is great in my project. I really appreciate
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33726892
very welcome...glad i helped you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question