pertama-tama ubah properti DrawMode Listbox menjadi : OwnerDrawFixed .
lalu copy kan kode berikut, dan lihat hasilnya .
Private Sub ListBox2_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox2.DrawItem
Dim Brush As New SolidBrush(Color.FromKnownColor(KnownColor.Control))
Brush.Color = Color.DarkGreen
e.DrawBackground()
e.Bounds.Y + ListBox2.ItemHeight)
If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
e.Graphics.FillRectangle(Brush, e.Bounds)
End If
Using b As New SolidBrush(e.ForeColor)
e.Graphics.DrawString(ListBox2.GetItemText(ListBox2.Items(e.Index)), e.Font, b, e.Bounds)
End Using
e.DrawFocusRectangle()
End Sub
Kata yang dicetak biru adalah warna yang akan di pakai , silahkan temen² ganti sesuai keinginan.
Selamat berkreasi
Tidak ada komentar:
Posting Komentar