Scusa,ora ho capito cosa intendi.
Per attivarlo o disattivarlo basta che crei 2 button :codice:Private Sub ListBox1_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem Dim TextItem As String = ListBox1.Items.Item(e.Index).ToString If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then ' Disegno il colore di sfondo nero e.Graphics.FillRectangle(New SolidBrush(Color.Black), e.Bounds) ' Disegno il testo di colore Rosso e lo metto in grassetto e.Graphics.DrawString(TextItem, New Font(e.Font, FontStyle.Bold), New SolidBrush(Color.Red), e.Bounds) Else ' disegno lo sfondo con il colore di default e.DrawBackground() ' disegno il testo con il colore di default e.Graphics.DrawString(TextItem, e.Font, Brushes.Black, e.Bounds) End If End Sub
codice:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.DrawMode = DrawMode.OwnerDrawFixed 'attivo End SubSe invece vuoi che la modifica si attiva quando si avvia il form,basta che lo metti al load :codice:Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ListBox1.DrawMode = DrawMode.Normal 'disattivo End Sub
Credo che ora era quello che volevi.codice:Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ListBox1.DrawMode = DrawMode.OwnerDrawFixed 'attivo all'avvio End Sub

Rispondi quotando
