Kamis, 16 Mei 2013

Penggunaan Listview Pada Vb.net 2008

Design form penggunaan listview pada vb.net 2008





Berikut ini listing programnya :

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Nik.Items.Add("001")
        Nik.Items.Add("002")
        Nik.Items.Add("003")
        Jabatan.Items.Add("mandor")
        Jabatan.Items.Add("kepala bagian")
        Jabatan.Items.Add("staf")
        Status.Items.Add("menikah")
        Status.Items.Add("tidak menikah")

    End Sub
    Sub buattabel()
        Lv.Columns.Add("Nik", 50, HorizontalAlignment.Left)
        Lv.Columns.Add("Nama", 67, HorizontalAlignment.Left)
        Lv.Columns.Add("Jabatan", 85, HorizontalAlignment.Left)
        Lv.Columns.Add("Gaji", 65, HorizontalAlignment.Left)
        Lv.Columns.Add("Status", 90, HorizontalAlignment.Center)
        Lv.Columns.Add("Tunjangan Keluarga", 140, HorizontalAlignment.Left)
        Lv.Columns.Add("Pajak", 80, HorizontalAlignment.Left)
        Lv.Columns.Add("Total Gaji", 90, HorizontalAlignment.Left)
        Lv.View = View.Details
        Lv.GridLines = True
    End Sub

    Sub isitabel()
        Dim lst As New ListViewItem
        lst.Text = Nik.Text
        lst.SubItems.Add(Nama.Text)
        lst.SubItems.Add(Jabatan.Text)
        lst.SubItems.Add(Gaji.Text)
        lst.SubItems.Add(Status.Text)
        lst.SubItems.Add(TunjanganKeluarga.Text)
        lst.SubItems.Add(Pajak.Text)
        lst.SubItems.Add(Total.Text)
        Lv.Items.Add(lst)
    End Sub

    Private Sub Nik_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nik.SelectedIndexChanged
Select Nik.Text
            Case "001" : Nama.Text = "oncom"
            Case "002" : Nama.Text = "udin"
            Case "003" : Nama.Text = "ujang"
        End Select
    End Sub

    Private Sub Jabatan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Jabatan.SelectedIndexChanged
        Select Case Jabatan.Text
            Case "mandor" : Gaji.Text = 1750000
            Case "kepala bagian" : Gaji.Text = 2500000
            Case "staf" : Gaji.Text = 1250000
        End Select
        Pajak.Text = 0.15 * Gaji.Text
    End Sub

    Private Sub Status_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Status.SelectedIndexChanged
        Select Case Status.Text
            Case "menikah" : TunjanganKeluarga.Text = 0.15 * Gaji.Text
            Case "tidak menikah" : TunjanganKeluarga.Text = 0
        End Select
    End Sub

    Private Sub BtnSimpankelistview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSimpankelistview.Click
        isitabel()
        Nik.Text = ""
        Nama.Text = ""
        Jabatan.Text = ""
        Gaji.Text = ""
        Status.Text = ""
        TunjanganKeluarga.Text = ""
        Pajak.Text = ""
        Total.Text = ""
    End Sub

    Private Sub BtnBersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBersih.Click
        Nik.Text = ""
        Nama.Text = ""
        Jabatan.Text = ""
        Gaji.Text = ""
        Status.Text = ""
        TunjanganKeluarga.Text = ""
        Total.Text = ""
        Pajak.Text = ""
    End Sub

    Private Sub BtnDiPilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDiPilih.Click
        Lv.Items.Remove(Lv.SelectedItems(0))
    End Sub

    Private Sub BtnProses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnProses.Click
        Total.Text = Val(Gaji.Text) + Val(TunjanganKeluarga.Text) - Val(Pajak.Text)
    End Sub

    Private Sub BtnSemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSemua.Click
        Lv.Items.Clear()
    End Sub

    Private Sub BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnKeluar.Click
        End
    End Sub
End Class


Maka hasilnya akan muncul seperti gambar dibawah ini 



Untuk melihat Tugas TI-P1101, klik di sini 











Tidak ada komentar: