Memperbaiki Isi Listview


DESAIN AWAL









Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i = 1 To 5
            kode.Items.Add("P-00" & i)
            jumlah.Items.Add(i)
        Next
        With lv
            .Columns.Add("Kode", 50, HorizontalAlignment.Center)
            .Columns.Add("Nama", 220, HorizontalAlignment.Center)
            .Columns.Add("Harga", 80, HorizontalAlignment.Center)
            .Columns.Add("Jumlah", 50, HorizontalAlignment.Center)
            .Columns.Add("Total Harga", 100, HorizontalAlignment.Center)
            .View = View.Details
            .GridLines = True
            .FullRowSelect = True
        End With

    End Sub

    Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
        Select Case kode.Text
            Case "P-001"
                nama.Text = "Televisi Sony 21 Inchi"
                harga.Text = 2100000
            Case "P-002"
                nama.Text = "Televisi Sony 14 Inchi"
                harga.Text = 1900000
            Case "P-003"
                nama.Text = "Televisi Sony 29 Inchi"
                harga.Text = 2900000
            Case "P-004"
                nama.Text = "Televisi Sony 32 Inchi"
                harga.Text = 3500000
            Case "P-005"
                nama.Text = "Televisi Sony 40 Inchi"
                harga.Text = 4500000
            Case Else
                nama.Text = ""
                harga.Text = 0
        End Select
    End Sub

    Private Sub jumlah_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlah.SelectedIndexChanged
        tharga.Text = jumlah.Text * harga.Text
    End Sub


    Private Sub input_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles input.Click
        Dim p As Double = 0
        Dim a As New ListViewItem
        a.Text = kode.Text
        a.SubItems.Add(nama.Text)
        a.SubItems.Add(harga.Text)
        a.SubItems.Add(jumlah.Text)
        a.SubItems.Add(tharga.Text)
        lv.Items.Add(a)

        For i = 0 To lv.Items.Count - 1
            p = p + lv.Items(i).SubItems(4).Text
        Next
        penjualan.Text = p

        kode.Text = ""
        nama.Text = ""
        harga.Text = ""
        jumlah.Text = ""
        tharga.Text = ""
    End Sub

    Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
        End
    End Sub

    Private Sub lv_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lv.SelectedIndexChanged
        kode.Text = lv.SelectedItems(0).SubItems(0).Text
        nama.Text = lv.SelectedItems(0).SubItems(1).Text
        harga.Text = lv.SelectedItems(0).SubItems(2).Text
        jumlah.Text = lv.SelectedItems(0).SubItems(3).Text
        tharga.Text = lv.SelectedItems(0).SubItems(4).Text
    End Sub

    Private Sub edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit.Click
        Dim p As Double = 0
        lv.SelectedItems(0).SubItems(0).Text = kode.Text
        lv.SelectedItems(0).SubItems(1).Text = nama.Text
        lv.SelectedItems(0).SubItems(2).Text = harga.Text
        lv.SelectedItems(0).SubItems(3).Text = jumlah.Text
        lv.SelectedItems(0).SubItems(4).Text = tharga.Text

        For i = 0 To lv.Items.Count - 1
            p = p + lv.Items(i).SubItems(4).Text
        Next
        penjualan.Text = p
    End Sub
End Class


HASIL AKHIR
                                 


Memperbaiki Isi Listview Memperbaiki Isi Listview Reviewed by Pak Gulo on Maret 18, 2015 Rating: 5

Tidak ada komentar:

Diberdayakan oleh Blogger.