Getting error when showing data in list view, please help me.....
Error : Cannot add or insert the item '10-07-2018' in more than one place. You
must first remove it from its current location or clone it.
Parameter name: item

I use Vb.net 2010 visual basic
sql server 2008 r2
stored procedure
one listview

I want this type of structure (example)

id     date              item_name         qty.          amount
1      1/1/2019            a               2             10
                           B               1             12
                           x               14            100
                           zz              4             52

2      4/1/2019            M               5             80
                           N               4             50

But when I showing to the data 1st item show on list view then getting the error.
It is possible please help me

What I have tried:

With obj_S_J_RPT
               ListView1.Items.Clear()
               .Sdate = txtdtf.Text
               .EDate = txtdtt.Text
                dt1 = .GetStockJournalRPT()

               For i As Integer = 0 To dt1.Rows.Count - 1
                   Dim dr As DataRow = dt1.Rows(i)

               Dim listitem As New ListViewItem(dr("SJDate").ToString())
               listitem.SubItems.Add(dr("itemnmsou").ToString())
               listitem.SubItems.Add(dr("SJqty").ToString())
               listitem.SubItems.Add(dr("SJPCS").ToString())
               listitem.SubItems.Add(dr("SJRate").ToString())
               listitem.SubItems.Add(dr("SJamt").ToString())
               listitem.SubItems.Add(dr("SJleft").ToString())
               listitem.SubItems.Add(dr("nrr").ToString())
               listitem.SubItems.Add(dr("SJID").ToString())

               Try
                   With obj_S_J_RPT
                       'ListView2.Items.Clear()
                       .SJID = dr.Item(0)  'ListView1.Items(0).SubItems(8).Text
                       dt2 = .GetStockJournalDetails() 'change

                       For i1 As Integer = 0 To dt2.Rows.Count - 1
                           Dim dr1 As DataRow = dt2.Rows(i1)
                          ListViewItem(dr1("itemnmDES").ToString())

                           listitem.SubItems.Add(dr1("itemnmDES").ToString())
                           listitem.SubItems.Add(dr1("SJdqty").ToString())
                           listitem.SubItems.Add(dr1("SJdPCS").ToString())
                           listitem.SubItems.Add(dr1("SJdRate").ToString())
                           listitem.SubItems.Add(dr1("SJdamt").ToString())
                           listitem.SubItems.Add(dr1("SJDstock").ToString())
                           listitem.SubItems.Add(dr1("SJid").ToString())
                           ListView1.Items.Add(listitem)

                       Next i1
                   End With
               Catch ex As Exception
                   MsgBox(ex.Message, MsgBoxStyle.Critical)
               End Try

               ListView1.Items.Add(listitem)
           Next
       End With

Coding like the following you get the attached image:

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ListView1.View = View.Details
        For i As Int32 = 0 To 3
            Dim ch As ColumnHeader = ListView1.Columns.Add("Column " + (i + 1).ToString)
            ch.Width = 100
        Next

        With ListView1
            Dim vDates() As String = {"2019/01/01", "2019/01/01", "2019/01/01", "2019/01/02", "2019/01/02"}
            Dim lastID As Int32 = -1
            For id = 1 To 5
                Dim lastD As String = ""
                For Each d In vDates
                    Dim vFields() As String = {
                    " field A",
                    " field B"
                        }
                    Dim li As ListViewItem
                    If id <> lastID Then
                        li = .Items.Add(id.ToString)
                        lastID = id
                    Else
                        li = .Items.Add("")
                    End If
                    If d <> lastD Then
                        li.SubItems.Add(d)
                        lastD = d
                    Else
                        li.SubItems.Add("")
                    End If
                    For iRow As Int32 = 0 To vFields.Length - 1
                        Dim str As String = "ID:" + id.ToString + " date:" + d
                        li.SubItems.Add(str + vFields(iRow))
                    Next
                Next
            Next
        End With
    End Sub
End Class

ListView.PNG

thanks sir for replying but i can not marge my code with this code please help me sir....
how i can do this
please sir please help me sir please

commented: What can't you "marge" your code? I would be guessing why. +15

sorry sir that means how can i apply my code (for showing data ) with this strucher

commented: I'd have to guess what a strucher is. Maybe it's just some English issue. Do you have forums in your own language you can try? +0

sorry sir forgive me i don't know good english
in my language have no forum .
actully i want to put my code in you suggested example. means example data is manually input but it is live

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.