
Originariamente inviata da
Paki243
La listview non l'ho mai usata anche perchè non so se si puo fare (la listbox e la listview sono 2 cose diversi),però girando sul sito della Microsoft ho trovato la formula drawitem per la listview.
codice:
Imports System.Drawing.Drawing2D
Public Class Form1
Public Event DrawItem As DrawListViewItemEventHandler
Private Sub ListView1_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawListViewItemEventArgs) Handles ListView1.DrawItem
If Not (e.State And ListViewItemStates.Selected) = 0 Then
' Draw the background for a selected item.
e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds)
e.DrawFocusRectangle()
Else
' Draw the background for an unselected item.
Dim brush As New LinearGradientBrush(e.Bounds, Color.Orange, _
Color.Maroon, LinearGradientMode.Horizontal)
Try
e.Graphics.FillRectangle(brush, e.Bounds)
Finally
brush.Dispose()
End Try
End If
' Draw the item text for views other than the Details view.
If Not Me.ListView1.View = View.Details Then
e.DrawText()
End If
End Sub
End Class
Solo che la formula non l'ho testata quindi non so se funziona al 100%.