Listview need help!!!
-
Wednesday, May 09, 2012 1:56 AM
Can anyone help me...
The error occurs when i have added cat = ListView1.SelectedItem.ListSubItems(8), it says "Index out of bounds"... i have to display the data from the listview to my 20 textboxes. but when i added the category cat the index is out of bounds. and when i added more info and do the same it also give the same error......can anyone help me on this..thanks a lot.... me = ID no.
Name= Name of Employee
departement =Department
divisi = Division
status = Status
ttl = date
gender =sex
cat = type
permanent =permanent
resident=resident
Private Sub ListView1_Click()
roat
End Sub
Private Sub roat()
If ListView1.ListItems.Count = 0 Then Exit Sub
For i = 0 To ListView1.ListItems.Count
me = ListView1.SelectedItem
name = ListView1.SelectedItem.SubItems(1)
department = ListView1.SelectedItem.SubItems(2)
division = ListView1.SelectedItem.SubItems(3)
status = ListView1.SelectedItem.SubItems(4)
date = ListView1.SelectedItem.SubItems(5)
gender = ListView1.SelectedItem.ListSubItems(6)
Location = ListView1.SelectedItem.ListSubItems(7)
cat = ListView1.SelectedItem.ListSubItems(8)permanent = ListView1.SelectedItem.ListSubItems(9)
resident = ListView1.SelectedItem.ListSubItems(10)
'
'
'
Next
txtID.Text = me
txtName.Text = name
cbodept.Text = department
cbounit.Text = division
cbostat.Text = status
DTPicker1.Value = date
cbosex.Text = gender
txtaddress.Text = Location
cbotype.Text = cat
txtpermanent.Text = permanent
txtresident.Text = resident
Konek_Recordset rscarp, "Select * from kapal where me=" & me
If kapal.RecordCount = 0 Then Exit Sub
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
If IsNull(kapal.Fields("photo")) = False Then
mstream.Write rscaripic.Fields("photo").Value
mstream.SaveToFile "" & App.Path & "\image\photo.gif", adSaveCreateOverWrite
Image4.Picture = LoadPicture("" & App.Path & "\image\photo.gif")
Else
Image4.Picture = LoadPicture("" & App.Path & "\image\cewe.gif")
End If
End Sub
- Moved by Mark Liu-lxf Thursday, May 10, 2012 2:41 AM (From:Visual Basic General)
All Replies
-
Wednesday, May 09, 2012 8:53 AM
Hallo Chesta,
Did you know that Ado.Net, DataBinding and a DataGridView gives easier and more stable results than the vintage way you are currently using with setting everything, using the listview for data and old AdoDB for database.
http://www.vb-tips.com/CurrencyManager.aspx
In this simple sample is also the data created and of course there is no textbox but only a label to show.
Try it and when you are ready, change the database part with the code from this sample.
http://www.vb-tips.com/StronglyTypedDataSet.aspx
And then not for the Northwind database but your own database.
Success
Cor -
Wednesday, May 09, 2012 9:14 AM
hello...
is this vb6 codes???
-
Wednesday, May 09, 2012 9:17 AM
-
Wednesday, May 09, 2012 9:53 AM
Duh,
No this forum is not for vintage VB, try this link for that.
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b
Success
Cor- Edited by Cor LigthertMVP Wednesday, May 09, 2012 9:53 AM
-
Wednesday, May 09, 2012 2:58 PMWhy do people still use VB6?! It's been around longer than I have and VB6 is 21 years old.
Jordan St. Godard | Microsoft® Community Contributor 2011
double twoCents = .02; Console.WriteLine("$" + twoCents.ToString()); -
Wednesday, May 09, 2012 3:33 PM
For i = 0 To ListView1.ListItems.Count
Arrays start at 0, not 1, so use "ListView1.ListItems.Count - 1" (without the quotes).
Just a point out :)
If a post is helpful to you or solves a problem, remember to mark it as answer, propose it as answer or vote up.
Check out my development so far! -
Thursday, May 10, 2012 12:49 AM
thanks for the help..
:)
-
Thursday, May 10, 2012 2:41 AM
Hi chesca03302010,
Welcome to the MSDN forum.
This queue is a VB.Net forum. So your topic about VB6 is unsuitable here. I will move this thread to off-topic forum. Please follow members’ redirection to post your thread to the correct forum.
Sorry for any inconvenience and have a nice day.
Mark Liu-lxf [MSFT]
MSDN Community Support | Feedback to us