Kamis, 21 April 2011

Membuat ListView

Lansung aja bos......
kita bikin form seperti berikut:


seperti byasa kita kasih syntaknya sbb:

Public Class Data_Karyawan
Dim listtxt(11) As String
Dim listitem As ListViewItem

Private Sub Data_Karyawan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call isicombo1()
Call isicombo2()
Call isicombo3()
Call isibersih()
Call setlistview()
End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

End Sub

Sub isicombo1()
ComboBox1.Items.Add("Laki-laki")
ComboBox1.Items.Add("Permpuan")

End Sub

Sub isicombo2()
ComboBox2.Items.Add("Belum Menikah")
ComboBox2.Items.Add("Menikah")
End Sub

Sub isicombo3()
ComboBox3.Items.Add("Kepala Sekolah")
ComboBox3.Items.Add("Wakil Kepala Sekolah")
ComboBox3.Items.Add("Guru")
ComboBox3.Items.Add("Keuangan")
ComboBox3.Items.Add("Tata Usaha")
End Sub

Sub isibersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
ComboBox1.Text = "Laki-laki"
ComboBox2.Text = "Menikah"
ComboBox3.Text = "Kepala Sekolah"

End Sub

Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If Button1.Text = "Tambah" Then
Button1.Text = "Simpan"
Button2.Enabled = False
Button3.Enabled = False
Button4.Text = "Batal"
Else
listtxt(0) = Trim(TextBox5.Text)
listtxt(1) = Trim(TextBox1.Text)
listtxt(2) = Trim(TextBox2.Text)
listtxt(3) = Trim(TextBox3.Text)
listtxt(4) = Trim(ComboBox1.Text)
listtxt(5) = Trim(TextBox4.Text)
listtxt(6) = Trim(ComboBox2.Text)
listtxt(7) = Trim(ComboBox3.Text)
listtxt(8) = Trim(TextBox7.Text)
listtxt(9) = Trim(TextBox8.Text)
listtxt(10) = Trim(TextBox6.Text)
listitem = New ListViewItem(listtxt)
ListView1.Items.Add(listitem)
End If
End Sub
Sub setlistview()
ListView1.View = View.Details
ListView1.Columns.Add("No.Absen", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("NIK", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Nama Karyawan", 300, HorizontalAlignment.Left)
ListView1.Columns.Add("Tempat/Tanggal Lahir", 200, HorizontalAlignment.Left)
ListView1.Columns.Add("Jenis Kelamin", 100, HorizontalAlignment.Left)
ListView1.Columns.Add("Alamat", 300, HorizontalAlignment.Left)
ListView1.Columns.Add("Status", 100, HorizontalAlignment.Left)
ListView1.Columns.Add("Jabatan", 200, HorizontalAlignment.Left)
ListView1.Columns.Add("Tanggal Masuk", 100, HorizontalAlignment.Left)
ListView1.Columns.Add("Tanggal Sekarang", 100, HorizontalAlignment.Left)
ListView1.Columns.Add("Masa Kerja", 100, HorizontalAlignment.Left)
End Sub


Sub normal()
Button1.Text = "Tambah"
Button1.Enabled = True
Button2.Text = "Ubah"
Button2.Enabled = True
Button3.Text = "Hapus"
Button3.Enabled = True
Button4.Text = "Keluar"
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Button4.Text = "Keluar" Then
Fmenu.Show()
Me.Close()
Else
Call isibersih()
Call normal()
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Button2.Text = "Ubah" Then
Button1.Enabled = False
Button2.Text = "Simpan"
Button3.Enabled = False
Button4.Text = "Batal"
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Button3.Text = "Hapus" Then
Button1.Enabled = False
Button2.Enabled = False
Button3.Text = "OK"
Button4.Text = "Batal"
End If
End Sub
End Class

Monggo dicoba ! ! !

0 komentar:

Posting Komentar

 
cursor: url("http://kursor_anda.gif"), default;