Mengisi ListView Vb.net

 Kode berikut saya gunakan unt memasukkan data ke dalam listView, dan Saya Guakan untuk membuat Aplikasi kasir..

If LvKasir.Items.Count = 0 Then
            Dim ARR(5) As String
            ARR(0) = TxtKd_Brg.Text
            ARR(1) = TxtNm_Brg.Text
            ARR(2) = TxtSatuan.Text
            ARR(3) = TxtQty.Text
            ARR(4) = TxtH_Satuan.Text
            ARR(5) = TxtTotal.Text
            ' memyimpan data ke dalam listview
            Dim ListItem As ListViewItem
            ListItem = New ListViewItem
            ListItem = LvKasir.Items.Add(ARR(0))
            ListItem.SubItems.Add(ARR(1))
            ListItem.SubItems.Add(ARR(2))
            ListItem.SubItems.Add(ARR(3))
            ListItem.SubItems.Add(ARR(4))
            ListItem.SubItems.Add(ARR(5))
        Else
            'cari kode barang yang sama
            Dim result As Boolean = False
            Dim itemindex As Integer
            For Each item As ListViewItem In LvKasir.Items
                If item.Text = TxtKd_Brg.Text Then
                    result = True
                    itemindex = item.Index
                    Exit For
                End If
            Next
            If result = True Then 'jika barang sama
                Dim ARR(5) As String
                ARR(0) = TxtKd_Brg.Text
                ARR(1) = TxtNm_Brg.Text
                ARR(2) = TxtSatuan.Text
                ARR(3) = TxtQty.Text
                ARR(4) = TxtH_Satuan.Text
                ARR(5) = TxtTotal.Text
                LvKasir.Items(itemindex).SubItems(3).Text = (CDbl(LvKasir.Items(itemindex).SubItems(3).Text) + CDbl(ARR(3))).ToString ' update listview unt qty nya
            Else 'jika barang beda
                Dim ARR(5) As String
                ARR(0) = TxtKd_Brg.Text
                ARR(1) = TxtNm_Brg.Text
                ARR(2) = TxtSatuan.Text
                ARR(3) = TxtQty.Text
                ARR(4) = TxtH_Satuan.Text
                ARR(5) = TxtTotal.Text

                Dim ListItem As ListViewItem
                'ListItem = New ListViewItem
                ListItem = LvKasir.Items.Add(ARR(0))
                ListItem.SubItems.Add(ARR(1))
                ListItem.SubItems.Add(ARR(2))
                ListItem.SubItems.Add(ARR(3))
                ListItem.SubItems.Add(ARR(4))
                ListItem.SubItems.Add(ARR(5))
            End If
        End If

Terima kasih unt : djiesoft.blogspot.com yang sudah membantu,

Comments

Popular Posts