Solved

ArgumentOutofRangeException was unhandled in visual studio 2008

Posted on 2010-09-21
5
482 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
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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tabcontrol Caption? 1 29
Clone Visual studio 2013 solution 5 24
Help with WinAPI Signatures in VB.NET for SetWindowSubclass 2 34
Close form "before" open 3 23
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

914 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

19 Experts available now in Live!

Get 1:1 Help Now