60 likes | 175 Views
Object Listview dalam Windows Form. . Arfansyah, M.Kom. Listview. Listview : digunakan untuk menampilkan data yang bentuknya jamak. Public Class Form1 Dim nomor As Integer Sub Bersih() txtNama.Text = "" txtKelas.Text = "" txtPersen.Text = "" End Sub
E N D
Object Listview dalam Windows Form. Arfansyah, M.Kom
Listview • Listview : digunakan untuk menampilkan data yang bentuknya jamak.
Public Class Form1 Dim nomor As Integer Sub Bersih() txtNama.Text = "" txtKelas.Text = "" txtPersen.Text = "" End Sub Sub Tampilkan(ByVal No As Integer) txtNama.Text = LVAbsen.Items(No).SubItems(0).Text txtKelas.Text = LVAbsen.Items(No).SubItems(1).Text txtPersen.Text = LVAbsen.Items(No).SubItems(2).Text End Sub Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load LVAbsen.Columns.Add("Nama", 200, HorizontalAlignment.Left) LVAbsen.Columns.Add("Kelas", 100, HorizontalAlignment.Center) LVAbsen.Columns.Add("Persentase", 120, HorizontalAlignment.Center) End Sub
Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpan.Click nomor = LVAbsen.Items.Count LVAbsen.Items.Add(txtNama.Text) LVAbsen.Items(nomor).SubItems.Add(txtKelas.Text) LVAbsen.Items(nomor).SubItems.Add(txtPersen.Text) End Sub Private Sub btnCari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCari.Click Dim Cari As String Cari = InputBox("Masukkan Nama Mahasiswanya = ", "Masukkan Nama") For a As Integer = 0 To LVAbsen.Items.Count - 1 If LVAbsen.Items(a).SubItems(0).Text.ToUpper = Cari.ToUpper Then Tampilkan(a) Exit Sub End If Next a MessageBox.Show("Data tidak ditemukan ", "Maaf tidak ketemu") End Sub Private Sub btnHapusSemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapusSemua.Click LVAbsen.Items.Clear() Bersih() End Sub
Private Sub txtPersen_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPersen.KeyPress If Not (Char.IsNumber(e.KeyChar) Or Char.IsControl(e.KeyChar)) Then e.Handled = True MessageBox.Show("Masukkan nilai angka 0-100", "Terima Kasih") End If End Sub Private Sub txtPersen_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPersen.TextChanged If Not (Val(txtPersen.Text) >= 0 And Val(txtPersen.Text) <= 100) Then MessageBox.Show("Masukkan nilai angka 0-100", "Terima Kasih") txtPersen.Text = "" End If End Sub End Class