listview Cannot add or insert the item '02' in more than one place

franz081227

Member
Joined
Sep 1, 2008
Messages
8
Programming Experience
Beginner
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

Additional information: Cannot add or insert the item '02' in more than one place. You must first remove it from its current location or clone it.

That is the error when I am trying to view more than one records coming from my database. This is my chunk of code... please help me

VB.NET:
Expand Collapse Copy
Dim strsql As String
        Dim rs As New ADODB.Recordset
        Dim a As Integer = 1
        lvPartMain.Items.Clear()
        strsql = "Select * from part_m_tab"
        'Try
            With rs
                .Open(strsql, conn)
                Dim lvItem As New ListViewItem
                Do While Not .EOF
                    lvItem.Text = .Fields(0).Value 'm_partID
                    lvItem.SubItems.Add(.Fields(1).Value) 'm_partdesc
                    lvPartMain.Items.Add(lvItem)

                    .MoveNext()
                Loop
        End With
 
Last edited by a moderator:
You're doing Items.Add(lvItem) multiple times with the same lvItem (=ListViewItem), you need to create a new ListViewItem each time you want to add one.

Thread moved to to ListView forum, your request has nothing to do with the VS IDE.
 
You're doing Items.Add(lvItem) multiple times with the same lvItem (=ListViewItem), you need to create a new ListViewItem each time you want to add one.

Thread moved to to ListView forum, your request has nothing to do with the VS IDE.

how will i do that sir??? i am new in vb.net and i try my best to understand it please reply i really want your help!!!!????:(
 
Back
Top