1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| procedure TfrmBases.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 ListBox1.Selected[Index]
then Brush.Color:=clYellow // Fond jaune pour l'Item sélectionné
else Brush.Color:=clWhite; // Fond blanc pour les autres
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 TfrmBases.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