Option Strict On Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 'indique à listbox2 de dessiner ses items par l'événement DrawItem ListBox2.DrawMode = DrawMode.OwnerDrawFixed 'ajout des éléments ListBox1.Items.AddRange({"banane", "orange", "citron"}) ListBox2.Items.AddRange({"citron", "orange", "banane"}) End Sub Private Sub ListBox2_DrawItem(sender As Object, e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox2.DrawItem 'si les textes sont différents... If CType(ListBox1.Items(e.Index), String) <> CType(ListBox2.Items(e.Index), String) Then 'affichage d'un rectangle rouge e.Graphics.FillRectangle(Brushes.Red, e.Bounds) Else 'affichage rectangle vert e.Graphics.FillRectangle(Brushes.GreenYellow, e.Bounds) End If 'affichage du texte e.Graphics.DrawString(ListBox2.Items(e.Index).ToString, e.Font, Brushes.Black, New PointF(e.Bounds.Left, e.Bounds.Top)) End Sub End Class
listcorriger.DrawMode = DrawMode.OwnerDrawFixed
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionest ce que je peux appeler la fonction dans le code du bouton corriger c tt