| | |
VB.Net: Problem Retrieve data from ListView
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2006
Posts: 24
Reputation:
Solved Threads: 0
Hi there,
I am having problem trying to retrieve the data from ListView the 2nd time round. It works the first time I clicked on the Line Item and when I clicked on another line item it gave me this error message :-
"Specific argument ws out of the range of valid values. Parameter name : Index
Here are the sample scipts:-
Private Sub ListClient_SelectedIndexChanged( _
ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListClient.SelectedIndexChanged
Dim intIndex As Integer
Try
With ListClient
intIndex = .SelectedIndices(0)
lngPClientId = .Items(intIndex).Text
Me.lblClientId.Text = lngPClientId
txtClientName.Text = .Items(intIndex).SubItems(1).Text
txtAcctMgr.Text = .Items(intIndex).SubItems(2).Text
intIndex = 0
End With
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Please help me. Thanks
Have a Good Day,
Cheers,
Lennie
I am having problem trying to retrieve the data from ListView the 2nd time round. It works the first time I clicked on the Line Item and when I clicked on another line item it gave me this error message :-
"Specific argument ws out of the range of valid values. Parameter name : Index
Here are the sample scipts:-
Private Sub ListClient_SelectedIndexChanged( _
ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListClient.SelectedIndexChanged
Dim intIndex As Integer
Try
With ListClient
intIndex = .SelectedIndices(0)
lngPClientId = .Items(intIndex).Text
Me.lblClientId.Text = lngPClientId
txtClientName.Text = .Items(intIndex).SubItems(1).Text
txtAcctMgr.Text = .Items(intIndex).SubItems(2).Text
intIndex = 0
End With
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Please help me. Thanks
Have a Good Day,
Cheers,
Lennie
hi ,
When you select the first row there is no problem coz the event fires once ok, but the problem accurse when you select other row coz the event (which is ListView1_SelectedIndexChanged) fires twice once for deselect the first row and the other for select the second row. So the message "Specific argument was out of the range of valid values. Parameter name: Index " show because deselect the first row you chosen. I hope I could explain well :cheesy:
Any way the solution is by adding if statement before the retrieve of the list row information
When you select the first row there is no problem coz the event fires once ok, but the problem accurse when you select other row coz the event (which is ListView1_SelectedIndexChanged) fires twice once for deselect the first row and the other for select the second row. So the message "Specific argument was out of the range of valid values. Parameter name: Index " show because deselect the first row you chosen. I hope I could explain well :cheesy:
Any way the solution is by adding if statement before the retrieve of the list row information
VB.NET Syntax (Toggle Plain Text)
If ListClient.SelectedItems.Count = 0 Then Exit Sub Try With ListClient intIndex = .SelectedIndices(0) lngPClientId = .Items(intIndex).Text Me.lblClientId.Text = lngPClientId txtClientName.Text = .Items(intIndex).SubItems(1).Text txtAcctMgr.Text = .Items(intIndex).SubItems(2).Text intIndex = 0 End With Catch ex As Exception MessageBox.Show(ex.Message) End Try
•
•
Join Date: Mar 2006
Posts: 24
Reputation:
Solved Threads: 0
•
•
•
•
hi ,
When you select the first row there is no problem coz the event fires once ok, but the problem accurse when you select other row coz the event (which is ListView1_SelectedIndexChanged) fires twice once for deselect the first row and the other for select the second row. So the message "Specific argument was out of the range of valid values. Parameter name: Index " show because deselect the first row you chosen. I hope I could explain well :cheesy:
Any way the solution is by adding if statement before the retrieve of the list row information
VB.NET Syntax (Toggle Plain Text)
If ListClient.SelectedItems.Count = 0 Then Exit Sub Try With ListClient intIndex = .SelectedIndices(0) lngPClientId = .Items(intIndex).Text Me.lblClientId.Text = lngPClientId txtClientName.Text = .Items(intIndex).SubItems(1).Text txtAcctMgr.Text = .Items(intIndex).SubItems(2).Text intIndex = 0 End With Catch ex As Exception MessageBox.Show(ex.Message) End Try
Thanks for taking time to explain the situation to me. Now, I understand why I am getting those error message. And also thanks for the sample scripts.
Cheers,
Lennie
Last edited by LennieKuah; Feb 10th, 2007 at 10:30 pm. Reason: typo errors
![]() |
Similar Threads
- retrieve data from database into jsp(urgent)!!! (Oracle)
- How to retrieve data from a dynamically generated radio button (ASP.NET)
- Modify data in Datagrid (VB.NET)
- retrieve data by VB.Net (VB.NET)
- ASP.NET 2.0, Parent/Child Data Control? (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: defeated
- Next Thread: Project Help
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account arithmetic array basic beginner bing browser button buttons center check code combobox crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags hardcopy html images input insert intel internet mobile monitor ms net networking objects open output panel passingparameters pdf picturebox picturebox1 port position printing problem project save searchvb.net select serial settings shutdown soap sqlserver survey tcp temperature text textbox timer timespan toolbox transparency trim update updown user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet view visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode year





