Solved

ArgumentOutofRangeException was unhandled in visual studio 2008

Posted on 2010-09-21
5
481 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
  • 4
5 Comments
 
LVL 18

Expert Comment

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

Expert Comment

by:John (Yiannis) Toutountzoglou
Comment Utility
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 500 total points
Comment Utility
try my code in Listview Click or double click event
0
 

Author Comment

by:angel7170
Comment Utility
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
Comment Utility
very welcome...glad i helped you
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now