1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin ListBox1.Style:=(lbOwnerDrawFixed);
with ListBox1.Canvas do
begin Font.Color:=clBlack; // Couleur de fonte
if Odd(Index) then Brush.Color:=clAqua // Couleur d'arrière plan
else Brush.Color:=clWhite; // alternée bleu/blanc
FillRect(Rect); // Remplit le rectangle de l'Index sur canvas avec Brush.color
TextOut(Rect.Left, Rect.Top, ListBox1.Items[Index]); // Texte de l'Item
end;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var i:integer;
begin for i:=0 to ListBox1.Items.Count-1
do ListBox1DrawItem(ListBox1,i,ListBox1.ItemRect(i),[odDefault]);
end; |
Partager