Standarnya sih listview emang enggak nyediain properti untuk ngeset warna
barisnya, tapi kita bisa buat sendiri prosedure untuk ngeset warna barisnya
dengan memanfaatkan properti picturenya, selain itu kita juga membutuhkan objek
picturebox
ini cuplikan kodenya :
Private Sub setRowColorListView(ByVal pic As PictureBox, ByVal lst As
ListView)
Dim i As Long
pic.BackColor = lst.BackColor
pic.ScaleMode = vbTwips
pic.BorderStyle = vbBSNone
pic.AutoRedraw = True
pic.Visible = False
pic.Width = lst.Width
pic.Height = lst.ListItems(1).Height * (lst.ListItems.Count)
pic.ScaleHeight = lst.ListItems.Count
pic.ScaleWidth = 1
pic.DrawWidth = 1
pic.Cls
For i = 1 To lst.ListItems.Count
If i Mod 2 = 0 Then
'warna putih
pic.Line (0, i - 1)-(1, i), RGB(255, 255, 255), BF
Else
pic.Line (0, i - 1)-(1, i), RGB(239, 239, 239), BF
End If
Next
lst.Picture = pic.Image
End Sub
untuk ngeset warna tulisannya pake yang ini :
Private Sub setFontColorListView(ByVal lst As ListView, ByVal iRow As Long,
ByVal warna As Long)
Dim iCol As Byte
With lst
.ListItems(iRow).ForeColor = warna
.ListItems(iRow).Bold = True
For iCol = 1 To lst.ColumnHeaders.Count - 1
.ListItems(iRow).ListSubItems.Item(iCol).ForeColor = warna
.ListItems(iRow).ListSubItems.Item(iCol).Bold = True
Next
.Refresh
End With
End Sub
Private Sub Command1_Click()
Call setRowColorListView(Picture1, ListView1)
End Sub
Private Sub Command2_Click()
'3 -> baris yang ingin diset warnanya misal merah
Call setFontColorListView(ListView1, 3, vbRed)
End Sub
selamat mencoba :)
hendra putra <[EMAIL PROTECTED]> wrote:
siang VB'ers
Gimana Cara memberi warna list view per row, jadi row genap dan ganjil beda
warna, saya gunakan list view tipe reportlist
.trus kalo colom id sudah ada tersimpan datanya saya ingin untuk merubah warna
tulisanya warna merah baris yang bersangkutan...
gimana caranya tolong dong.
THX
hendra
__________________________________________________________
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
http://new.toolbar.yahoo.com/toolbar/features/mail/index.php
[Non-text portions of this message have been removed]
---------------------------------
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
[Non-text portions of this message have been removed]