Menampilkan Data dengan List View

4 Juni 2010 at 11:24 Tinggalkan komentar

Buka Project Baru, tambahkan sebuah form baru, tambahkan kedalamnya sebuah listview dan sebuah command button lalu copy paste code dibawah ini :

Private Sub Command1_Click()

Adodc1.ConnectionString =  _
“Provider=Microsoft.Jet.OLEDB.4.0;” + _
“Data Source=” + App.Path + “\db5.mdb;Persist Security Info=False”
Adodc1.RecordSource = “Products”  ‘nama tabel
Adodc1.Refresh

‘set tampilan listview1
Dim fnt As New StdFont
fnt.Name = “Arial”
fnt.Size = 8

With ListView1
.View = lvwReport

.ColumnHeaders.Add , , “Product ID”, 1500
.ColumnHeaders.Add , , “Product Name”, 2500
.ColumnHeaders.Add , , “Supplier”, 1500
.ColumnHeaders.Add , , “Category”, 1500
.ColumnHeaders.Add , , “Qty / Unit”, 1000
.ColumnHeaders.Add , , “Price”, 1000, 1
.ColumnHeaders.Add , , “Stock”, 1000, 1
.ColumnHeaders.Add , , “Order”, 1000, 1

.GridLines = True ‘ tambahan grid, untuk versi 6 lebih lengkap propertiesnya, bisa dicoba sendiri
.MultiSelect = True
Set .Font = fnt
End With

‘mengisi listview
Adodc1.Recordset.MoveFirst
Do Until Adodc1.Recordset.EOF
With ListView1
.ListItems.Add , , Adodc1.Recordset(0)
.ListItems(.ListItems.Count).SubItems(1) = _
Adodc1.Recordset(1)
.ListItems(.ListItems.Count).SubItems(2) =  _
Adodc1.Recordset(2)

End With
Adodc1.Recordset.MoveNext
Loop
End Sub

Contoh Projectnya dapat didownload disini : [ http://www.vbjadul.com/2010/06/menampilkan-data-dengan-listview-dan.html ]

Entry filed under: LISTVIEW. Tags: .

Cara membuat Menu Pada Visual Basic 6.0

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Arsip

Pos-pos Terbaru

Feeds


%d blogger menyukai ini: