Contoh Applikasi Listview





Public Class Form_petugas
Dim listtxt(3) As String
Dim listitem As ListViewItem

Private Sub Form_petugas_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call Bersih()
End Sub

Sub Bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub

Private Sub Form_petugas_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call listview()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
listtxt(0) = Trim(TextBox1.Text)
listtxt(1) = Trim(TextBox2.Text)
listtxt(2) = Trim(TextBox3.Text)
listitem = New ListViewItem(listtxt)
ListView1.Items.Add(listitem)
End Sub

Sub listview()
ListView1.View = View.Details
ListView1.Columns.Add("Kode Petugas", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Nama Petugas", 300, HorizontalAlignment.Center)
ListView1.Columns.Add("Shift", 50, HorizontalAlignment.Center)
End Sub

Private Sub ListView1_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles ListView1.ItemSelectionChanged
TextBox1.Text = e.Item.Text
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Button4.Text = "Keluar" Then
MsgBox("Anda Yakin Akan Keluar? ")
Me.Close()
Else
Call Bersih()
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'Call hapus()
ListView1.Items.RemoveAt(0)
ListView1.Items.RemoveAt(1)
ListView1.Items.RemoveAt(2)
End Sub

Sub hapus()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
ListView1.Items.Clear()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Call edit()
End Sub
Sub edit()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub

Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
End Sub
End Class

Komentar

Postingan Populer