setelah disimpan data di listview langsung nambah tanpa harus refresh lagi.

Sebagai contoh, buat project baru, tambahkan 3 buah TextBox, sebuah ListView, dan dua buah CommandButton.

Atur properti ListView:
View -=> 3-lvwReport
GridLines -=> True
FullRowSelect -=> True
Tambahkan 3 buah CoulumHeader di ListView tersebut, bisa kan?

Ubah Nama CommandButton, masing-masing: cmdSimpan dan cmdHapus

Ketik ni kode:

Code:
Option Explicit

Private Sub cmdSimpan_Click()
Dim mylist As ListItem
Dim TeksDicari As String
TeksDicari = Text1

Set mylist = Me.ListView1.FindItem(Text1, , , 1)

If mylist Is Nothing Then
Set mylist = Me.ListView1.ListItems.Add(, , Text1)
mylist.SubItems(1) = Text2
mylist.SubItems(2) = Text3
mylist.SubItems(3) = Text4
Else
mylist.Text = Text1
mylist.SubItems(1) = Text2
mylist.SubItems(2) = Text3
mylist.SubItems(3) = Text4
End If

mylist.Selected = True
mylist.EnsureVisible
Me.ListView1.SetFocus
End Sub

Private Sub cmdHapus_Click()
Dim mylist As ListItem
Dim TeksDicari As String
TeksDicari = Text1

Set mylist = Me.ListView1.FindItem(Text1, , , 1)

If Not mylist Is Nothing Then
Me.ListView1.ListItems.Remove (mylist.Index)
Else
MsgBox “Data tidak ada”, 64
End If
End Sub

One thought on “setelah disimpan data di listview langsung nambah tanpa harus refresh lagi.

  1. New Dad Blog#Business says:

    Right here is the perfect website for anybody who wants to find out about this topic.
    You understand so much its almost tough to argue with you (not that I actually will need
    to…HaHa). You certainly put a new spin on a subject which has been written about
    for decades. Excellent stuff, just excellent!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s